Syntax error for simple script

Ben S. bxstover at yahoo.co.uk
Mon Jun 26 11:16:29 EDT 2017


Sorry for this newbie question:

I installed Python v3.6.1 on win 7. Afterwards I tried to execute the following simple python script from webpage http://www.pythonforbeginners.com/code-s...me-script/:


Python Code: 

from datetime import datetime
now = datetime.now()
mm = str(now.month)
dd = str(now.day)
yyyy = str(now.year)
hour = str(now.hour)
mi = str(now.minute)
ss = str(now.second)
print mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss
 
When executing

 D:\tools\python\python.exe dateParser.py

 it yields a syntax error:

  File "dateParser.py", line 17
    print mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss
           ^
 SyntaxError: Missing parentheses in call to 'print'

Whats wrong?

Thank you
Peter 



More information about the Python-list mailing list