i have a python3.6.0 script which works perfectly well on windows. but when i run it in bash i get syntax error. here is the code:
import itertools
lines=["Hamlet","William Shakespeare","Edited Barbara B Mowat Paul Werstine","Michael Poston Rebecca Niles","Folger Shakespeare Library","httpwwwfolgerdigitaltextsorgchapter5playHam","Created Jul 31 2015 FDT version 092","Characters Play","line 17 POLONIUS father Ophelia Laertes councillor King Claudiusthis line substituted GHOST"]
LinesMap=dict()
for line in lines:
list=[l for l in line.split(' ')]
d = dict(itertools.zip_longest(*[iter(list)] * 2, fillvalue=None))
LinesMap = {**LinesMap, **d}
print(LinesMap)
this is the error:
[reza@localhost ~]$ python New\ Text\ Document.py
File "New Text Document.py", line 16
LinesMap = {**LinesMap, **d}
^
SyntaxError: invalid syntax
LinesMap.update(d).longest_zipwhich also does not exist in Python 2. The proper solution is really to upgrade to the currently recommended and supported version of the language, which is Python 3.izip_longestexists. The code will not work with Python 3 then (except for some try-to-import tricks), but it might serve OP's needs. (Also, Python 2 is still supported, although not recommened)