Error in python IDE formatting print datetime


#1



https://www.codecademy.com/en/courses/python-beginner-en-zFPOx/0/5?curriculum_id=4f89dab3d788890003000096


TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'.


This error expect only in python ide, not codeacademy


print '%s/%s/%s' % (now.month, now.day, now.year)


#2

If you are on Pretty Time, separate your placeholders with colons: and not slashes / ,

to,

print '%s:%s:%s'


And change your values to hour, minute, and second here,


#3

Ok, in codeacademy server all worked, but in Visual studio code take this error:

%s:%s:%s
TypeError, unsupported operand type(s) for %: 'NoneType' and 'tuple'
Traceback (most recent call last):
File "c:\Users\User\Documents\Projects\Python3\Hello.py", line 4, in
print ('%s:%s:%s') % (now.hour, now.minute, now.second)
TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'


#4

In python 3.6.1 new syntax
print(now.day,now.month,now.year,sep='/')


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.