I am doing an online course and there is an excercise where I need to print the current time. The question looks like this-
2017-04-03
2017-04-03 07:47:48.436353
The date is outputted correctly but why does the time have the date before it and some random numbers after it?
What did I do wrong?
#Complete the code below. We've gone ahead and created #variables for the current date and current time. Now, #we want to print date with the format year/month/day, #and the time with the format hour:minute:second. from datetime import date import datetime todaysDate = date.today() currentTime = datetime.datetime.now() #Don't modify the code above! #Complete the line below to print today's date with the #form year/month/date. For example, January 15th, 2017 #would be 2016/1/15. print() #Complete the line below to print the current time with #the form hour:minute:second, such as 12:57:15. Don't worry #about the leading 0s for single-digit times. If it's #1:05PM and 7 seconds, the correct answer would be: #13:5:7 (13 because Python uses 24-hour timeby default). print() And this is what I did- #Complete the code below. We've gone ahead and created #variables for the current date and current time. Now, #we want to print date with the format year/month/day, #and the time with the format hour:minute:second. from datetime import date import datetime todaysDate = date.today() currentTime = datetime.datetime.now() #Don't modify the code above! #Complete the line below to print today's date with the #form year/month/date. For example, January 15th, 2017 #would be 2016/1/15. print(date.today()) #Complete the line below to print the current time with #the form hour:minute:second, such as 12:57:15. Don't worry #about the leading 0s for single-digit times. If it's #1:05PM and 7 seconds, the correct answer would be: #13:5:7 (13 because Python uses 24-hour timeby default). print(currentTime)But the output is coming as-
2017-04-03
2017-04-03 07:47:48.436353
The date is outputted correctly but why does the time have the date before it and some random numbers after it?
What did I do wrong?
Moderator Larz60+: Added Python tags. Please do this in the future (see help, BBCODE)