Jul-17-2019, 12:24 AM
this little test script works:
Output:lt2a/phil /home/phil 137> cat try.py
#!/usr/bin/env python3
a=[1,2,3,4,5,6]
b=[0,5,10]
for x in b:
if x in a:
print('foo')
break
else:
print('bar')
print('xyzzy')
lt2a/phil /home/phil 138> python3 try.py
foo
xyzzy
lt2a/phil /home/phil 139>
however, doing the same exact thing interactively gets a syntax error:Output:lt2a/phil /home/phil 139> python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a=[1,2,3,4,5,6]
>>> b=[0,5,10]
>>> for x in b:
... if x in a:
... print('foo')
... break
... else:
... print('bar')
... print('xyzzy')
File "<stdin>", line 7
print('xyzzy')
^
SyntaxError: invalid syntax
>>>
any idea what is wrong?
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.