Cant make simple Python program run through Windows command prompt -
so wrote simple python test file called test testprog.py, , looks this:
import sys def adder(a, b): sum = a+b print sum if __name__ == "__main__": = int(sys.argv[1]) b = int(sys.argv[2]) adder(a, b) from question here, did command:
python testprog.py 3 4 however following error message:
file "testprog.py", line 5 print sum ^ syntaxerror: invalid syntax i not sure issue it... can run python command prompt no issue, why cant replicate questions' solution?
thanks.
edit: python 3.4 used
it looks have python 3 installed. code running written python 2, has different syntax. example, need change print(sum). in general, should search around information on difference between python 2 , 3, , careful note version used in code find on internet. code written python 2 not run as-is on python 3.
Comments
Post a Comment