2017-08-29 22 views
-1

我試圖在python中做一個簡單的計時器和倒數計時器,但對於第一個問題,無論您選擇什麼類型的計時器或倒數計時器,它都會給您定時器而不是倒計時。我如何改變這一點?我如何在Python代碼中給出兩種可能的結果

import time 
    def resetVar(): 
x = input("Timer or countdown?:") 
minsum = int(input("How long do you want the timer to go?: ")) 
reminder = int(input("How often do we notify you in minutes?: ")) 
mins = 0 
countminsum = 0 
mins = 0 
x = input("Timer or countdown?:") 
if(x == "Timer" or "timer"): 
    minsum = int(input("How long do you want the timer to go?: ")) 
    reminder = int(input("How often do we notify you in minutes?: ")) 
    print("Countdown has started.") 
    while mins != minsum: 
     time.sleep(reminder * 60) 
     mins += reminder 
     print(str(reminder) + " Minute(s) have passed") 

    if mins == minsum: 
     print("timer has ended") 
     resetVar() 
     print(x) 
if(x == "Countdown" or "countdown"): 
    countminsum = int(input("How long shout the countdown go for?: ")) 
    remider = int(input("How often should we notify you how much time is left? (in minutes): ")) 
    print ("countdown has started") 
    while countminsum != mins: 
      time.sleep(remider * 60) 
      countminsum -= remider 
      printe(str(remider) + " Minute(s) have passed.") 

    if countminsum == 0: 
     print ("Countdown has ended.") 
     resetVar() 
     print (x) 
+0

請正確縮進您的代碼 –

回答

0

您不能檢查,如果x定時器或定時器這樣的,因爲它的計算結果爲x == 'Timer',("Timer" or "timer" == 'Timer'),而不是你可以說x in ['timer', 'Timer']

倒數也是如此。

相關問題