Python list comprehension overriding value
- by Joschua
Hi, folks
have a look at the following piece of code, which shows a list comprehension..
>>> i = 6
>>> s = [i * i for i in range(100)]
>>> print(i)
When you execute the code example in Python 2.6 it prints 99, but when you execute it in Python 3.x it prints 6.
What were the reason for changing the behaviour and why is the output 6 in Python 3.x?
Thank you in advance!