Date and Time error


#1

Can someone help please?

from datetime import datetime
now = datetime.now()

print '%s/%s/%s' '%s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)


#2

So to correctly "format" the print statement you need to instead of having individual quotes around your %s you need to just have one set of " " around them. So for example:

print "%s/%s/%s %s:%s:%s"

#3

Thank youuu :smiley: I was trying to solve this problem for like 20 minutes!


#4

Yeah I hate when I solve something correctly but I forgot a small puncuation mark or misspelled something so I completely understand xD Your done with this section now so on to Conditionals and Control Flow so have fun and happy coding! :smiley:


#5

and also can you help me with this one also I am a beginner so I could be making some amateur mistakes :/.

def greater_less_equal_5(answer):
if 5 - 4 :
return 1
elif 6 - 7:
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

It sais the second statement "elif" is wrong I couldn't understand why


#6

Pay attention to the instructions where it says answer greater than or answer less than... notice you have a parameter that is named answer... that should hint you into the right direction :smiley:


#7

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