Maybe this will help.
while-loop (while loop executes until condition becomes False)
while-loop (while loop executes until condition becomes False)
n = 5 # initial value while 0 <= n: # while value is greater or even 0 print(n) # print value n -= 1 # decrease value by one, go back to row #3 (loop)
Output:5
4
3
2
1
0
for-loop (for loop executes until exhausted):for i in range(5, -1, -1): # range from 5 to -1 (excluded) incremented by -1 on every step print(i)
Output:5
4
3
2
1
0
Python interactive interpreter has built-in help. At first it may seem too intimidating but if you really want to learn programming you should get acquainted with terminology and style of help. Just type >>> help('for')
, >>> help('while')
, >>> help(range)
(press Q to exit the help)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.