Jump to content

précision for i in range info


Sarapproche
Go to solution Solved by Sans-Visage,

Recommended Posts

  • Ancien Responsable Matière

Bonjour 🙂 

J'aurai besoin d'une petite précision je pense que c'est ça qui me décale tout à chaque fois

dans une boucle "for pos in range (x) :"  le premier tour, il prend la valeur de 0  ou de 1 ? 

 

exemple

mot = "coucou" 

for pos in range (len(mot)) :   ici ça va répeter la boucle 6 fois, il y a 6 pos : 0.1.2.3.4.5  ou 1.2.3.4.5.6 ? 

        lettre = mot[pos] 

 

ici  le "c" ira dans l'indice 0 car le 1er tour de pos vaut 0, ou dans l'indice 1 car le 1er tour de pos vaut 1 

 

pos 3 vaut "c" ou "u

 

Je sais pas si c'est très clair haha désolée...

merci d'avance pour les éclaircissements 😉 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...