Aug-13-2021, 02:56 PM
Did you know that Python comes with built-in help?
Quote:Why am I seeing 2 and 3 instead of 4 and 5 ?
>>> help('for') The "for" statement ******************* The "for" statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object: /.../ The for-loop makes assignments to the variables(s) in the target list. This overwrites all previous assignments to those variables including those made in the suite of the for-loop: for i in range(10): print(i) i = 5 # this will not affect the for-loop # because i will be overwritten with the next # index in the rangeHow to overcome? Maybe something like this:
>>> for i, j in enumerate(range(1, 4)): ... print(i+j, i+j+1) ... print(i+j+3, i+j+4) ... 1 2 4 5 3 4 6 7 5 6 8 9
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.