Indentation
Snaky
-
Snaky -
Snaky -
>>> jour = ['Dimanche, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi']
>>> a, b = 0, 0
>>> while a < 25:
a = a + 1
b = a % 7
print a, jour[b]
1
Traceback (most recent call last):
File "<pyshell#7>", line 4, in -toplevel-
print a, jour[b]
IndexError: list index out of range
Bon voilà...... et dès que je change le "print a, jour[b]" , tout foire à cause de l'indentation.... Bref ça merche pas anyway
Merci de votre aide.
Snaky
>>> a, b = 0, 0
>>> while a < 25:
a = a + 1
b = a % 7
print a, jour[b]
1
Traceback (most recent call last):
File "<pyshell#7>", line 4, in -toplevel-
print a, jour[b]
IndexError: list index out of range
Bon voilà...... et dès que je change le "print a, jour[b]" , tout foire à cause de l'indentation.... Bref ça merche pas anyway
Merci de votre aide.
Snaky
2 réponses
et hop
* ta liste ne contenait qu'un élément
*fais attention à l'indentation dans ta boucle while
Johan
Gates gave you the windows.
GNU gave us the whole house.(Alexandrin)
johand@horus:~$ python Python 2.3.4 (#2, Sep 24 2004, 08:39:09) [GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> jour = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'] >>> a, b = 0, 0 >>> while a < 25: ... a = a + 1 ... b = a % 7 ... print a, jour[b] ... 1 Lundi 2 Mardi 3 Mercredi 4 Jeudi 5 Vendredi .....
* ta liste ne contenait qu'un élément
*fais attention à l'indentation dans ta boucle while
Johan
Gates gave you the windows.
GNU gave us the whole house.(Alexandrin)