May-24-2024, 10:46 PM
if i run this from a file it works as expected. if i type the same code into interactive python, i get a syntax error. which is the mistake? is this really a syntax error?
Output:lt1a/forums/2 /home/forums 5> cat -n this.py
1 foo = []
2 for x in foo:
3 print('hi')
4 print('bye')
lt1a/forums/2 /home/forums 6> python3 this.py
bye
lt1a/forums/2 /home/forums 7> python3
Python 3.8.10 (default, Nov 22 2023, 10:22:35)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> foo = []
>>> for x in foo:
... print('hi')
... print('bye')
File "<stdin>", line 3
print('bye')
^
SyntaxError: invalid syntax
>>> print('bar')
bar
>>>
lt1a/forums/2 /home/forums 8>
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.