SyntaxError: invalid syntax when coding in python -
the code have is
>>> string import ascii_lowercase >>> collections import counter >>> open('example.txt') f: print counter(letter line in f letter in line.lower() if letter in ascii_lowercase)
however, i'm getting syntaxerror: invalid syntax
highlights counter
on line print counter...
, don't know why
in python3, print
function. therefore, need surround arguments parentheses when call it:
% python python 3.4.3 (default, oct 14 2015, 20:28:29) [gcc 4.8.4] on linux type "help", "copyright", "credits" or "license" more information. >>> print 1 file "<stdin>", line 1 print 1 ^ syntaxerror: missing parentheses in call 'print' >>> print(1) 1
Comments
Post a Comment