so I just got to see something that I could not understand on why it happens
I do understand there would always be better ways to do what I am trying to do below - but I am interested on knowing about this particular behavior rather than alternate solutions
Code below on python 3.5 - [ NOTE i have x that hold a value 21 and the same is used in list comprehension to create that value list and my understanding is that the "x" used in the list comprehension will just act as a pointer to iterate through str(values) and my assumption seems to fine with python 3.5 ]
>>> x = 21
>>> y = 6
>>> value = x * y
>>> value_as_list = [ int(x) for x in str(value) ]
>>> x
21
>>> y
6
>>> value
126
>>>
Now in python 2.7
>>> x = 21
>>> y = 6
>>> value = x * y
>>> value_as_list = [ int(x) for x in str(value) ]
>>> x
'6'
>>> y
6
>>> value
126
>>>
Just because I used the same variable "x" in my list comprehension - I could now see that "x" value is changed to '6' instead of 21 [ I guess its the last of the 126 ]
why does this happen when x is supposed to be immutable and even though I dint explicitly assign anything to "x" in my list comprehension?
or
May be this will help me understand something that I should?