In [1]: n = '4' != 'e'
In [2]: n
Out[2]: True
In [3]: while n = '4' != 'e':
File "<ipython-input-12-1aa2b5c52181>", line 1
while n = '4' != 'e':
^
SyntaxError: invalid syntax
The expression n = '4' != 'e'
has a boolean True
value in Python. However, when used in a while
loop, Python 2.7 complains to parse it as the loop condition. Why is it so?