Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Dates and Times in Python (2014) Dates and Times Time Deltas

When are time variables supposed to be singular and when are they supposed to be plural?

Is anyone one able to provide a clear explanation on when minutes should be used rather than minute?

For example:

tomorrow = datetime.datetime.now().replace(hour=9, minute=0) + datetime.timedelta(days=1)

appointment = datetime.timedelta(minutes = 45)

appointment = datetime.timedelta(minute = 45)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'minute' is an invalid keyword argument for this function

2 Answers

The best way in the example you posted is this. If you were asking a question related to the concept, would you use singular or plural. What does the minute hand on the clock say? Or 'It is the 47th minute of the hour'. How long is you ____? Or 'My meetings is 47 minutes long'.

The only definitive answer would be to use whatever keyword the function you are calling uses. For this you should check the documentation of each function. (There is no gaurantee that someone good at writing functions and programming will also be an expert grammarian.)

minutes is not a variable, but I understand why you would think so given it looks like you assign to them in the code appointment = datetime.timedelta(minutes = 45). When inside the parameters to a function they are called keyword arguments. Functions will have a few specified that you can use.

If you look up the documentation for a module (for example googling for "python 3 datetime" you'll find the datetime docs on python.org) where you can read what keyword arguments a function has.