Grand Finale


#1

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)

why is my code not running?


#2

put space in the comas


#3

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

The code prints in the console but it still says it is not in the right format!


#4

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


#5

you forgot a comma after the first "now.year". That should solve


#6

This should fix it
print '%s/%s/%s ' % (now.month, now.day, now.year) + '%s:%s:%s' % (now.hour, now.minute, now.second)


#7

on what line do we put the code ?


#8

The secret is to be careful with the right order.


#9

Im done this like that:

from datetime import datetime
now = datetime.now()

current_hour = now.hour
current_minute = now.minute
current_second = now.second
current_day = now.day
current_month = now.month
current_year = now.year

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