Time Calculator—Not Passing Tests

Tell us what’s happening:
When I enter the arguments manually, my code works as it should. For some reason the test module does not like my code. I think it might be because I return an empty string if the optional argument is not provided, but I don’t know. Could that be the problem? Is there a better way to do this?

Your code so far
if args == ():
numnum = ‘’
for name in day_name:
for arg in args:
if arg.lower() == name.lower():
numnum = day_name.index(name)

# use dict key to determine new day
if numnum == '':
    newd = ''
elif numnum + days_passed >= 7:
    newd = f', {days[(numnum + days_passed) % 7]}'
    newd = f', {days[numnum + days_passed]}'

print(f'{output_hour}:{output_min} {new_am_pm}{newd} {elapsed}')

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:81.0) Gecko/20100101 Firefox/81.0.

Challenge: Time Calculator

Link to the challenge:

Welcome to the forums @dalen.carr .

If this is the end of your code

then the problem is that you are not returning a string to the code that is calling your function (print returns None I believe). The tests call your function and then test the output against the correct output in the tests.

1 Like

jereme.a.gray is right, you function is lacking a return ...
Basically for testing, calling the function alone is wrong - because the function is meant to return a string, you need to call the function withint a print(), aka print( time_calculator(...) ) then and only then should it actually print out values.