Indentation

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

2 réponses

jisisv Messages postés 3678 Statut Modérateur 935
 
et hop
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)
0
Snaky
 
Merci bcp jisisv.

En " Python commande lines " , mon indentation est parfaite.
C'est dans le Shell que ça se complique. Quelle application doit faire quoi au juste ?

Et aurais tu des exemples d'intentation pour python Shell ?

Je vous en serais très reconaissant

Snaky
0