ANTZY21
ANTZY21

Reputation: 87

Appropriate datetime.time inputs

I think I am misunderstanding how datetime inputs are taken, it looks like a tuple but isn't apparently, please can someone explain why this doesn't work?

print(datetime.date(2000, 1, 1))

date1  = 1, 1, 2000
print(datetime.date(date1))

>2000-01-01 
>Error message: an integer is required (got type tuple)

Upvotes: 0

Views: 24

Answers (1)

Mr.Zeus
Mr.Zeus

Reputation: 474

The problem you are having is due to this line date1 = 1, 1, 2000. Basically what is wrong is that when you have the commas like that it turns the variable into a tuple, which is not variable type you want. How you would fix this is using a list:

print(datetime.date(2000, 1, 1))
date1  = [1, 1, 2000]
print(datetime.date(date1[0],date1[1],date1[2]))

Hope I helped!

-Zeus

Upvotes: 1

Related Questions