Python return not returning variables

后端 未结 1 1640
醉梦人生
醉梦人生 2021-01-28 18:17

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):
         


        
相关标签:
1条回答
  • 2021-01-28 18:42

    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)
    
    0 讨论(0)
提交回复
热议问题