Skip to content Skip to sidebar Skip to footer

Python Return Not Returning Variables

In this clock i made it initially asks for the user to input the time but when it wont return the time in variables. I get a Traceback (most recent call last): File 'C:/Document

Solution 1:

The return statement returns values, not variables. And if nothing is done with the returned values, they are discarded.

You call setTime() but do nothing with the values it returns.

You need to store the returned values in new names:

time, hour12, hour, mins, sec = setTime()

I used the same names as used in the setTime() function itself, but I could just as well have given them different names:

foo, bar, baz, spam, eggs = setTime()

and then used those names in the rest of the code:

print(baz, ":", spam, ":", eggs)

Post a Comment for "Python Return Not Returning Variables"