簡體   English   中英

如何要求用戶輸入c繼續執行並再次執行,或e停止執行並退出。 ? 請為我的代碼提供您的備注嗎?

[英]How to ask the user to enter c to continue and execute again or e to stop executing and exit. ? please I need your notes for my code?

我正在嘗試運行一個程序,要求用戶以大寫或小寫形式輸入字符c以重復執行我的程序,或者以字符e退出程序。 但是當我輸入另一個字符時,循環仍然繼續。 另外,我知道上下限的方法,但是仍然不知道在代碼中使用的方法。例如,如果用戶輸入大寫字母e或E&c或C,則“重要”,我需要您的注釋來編寫我的代碼,因為我剛開始編程。 提前致謝。

while char != "e" :
     h= int (raw_input("plase enter your hieght: "))
     w = int ( raw_input("please enter your wieght: "))
     BMI = w/h*h
     print ("your body mass is : ",BMI) 
     char = raw_input("plase enter c to contiune or e to exit: ")
if char == "e" and char != "c":
    char = ""
    print ("Thank you, bye!")

我正在嘗試運行一個程序,要求用戶以大寫或小寫形式輸入字符c以重復執行我的程序,或者以字符e退出程序。 但是當我輸入另一個字符時,循環仍然繼續。 另外,我知道上下限的方法,但是仍然不知道在代碼中使用的方法。例如,如果用戶輸入大寫字母e或E&c或C,則“重要”,我需要您的注釋來編寫我的代碼,因為我剛開始編程。 提前致謝。

while char != "e" :
     h= int (raw_input("plase enter your hieght: "))
     w = int ( raw_input("please enter your wieght: "))
     BMI = w/h*h
     print ("your body mass is : ",BMI) 
     char = raw_input("plase enter c to contiune or e to exit: ")
if char == "e" and char != "c":
    char = ""
    print ("Thank you, bye!")

我正在嘗試運行一個程序,要求用戶以大寫或小寫形式輸入字符c以重復執行我的程序,或者以字符e退出程序。 但是當我輸入另一個字符時,循環仍然繼續。 另外,我知道上下限的方法,但是仍然不知道在代碼中使用的方法。例如,如果用戶輸入大寫字母e或E&c或C,則“重要”,我需要您的注釋來編寫我的代碼,因為我剛開始編程。 提前致謝。

while char != "e" :
     h= int (raw_input("plase enter your hieght: "))
     w = int ( raw_input("please enter your wieght: "))
     BMI = w/h*h
     print ("your body mass is : ",BMI) 
     char = raw_input("plase enter c to contiune or e to exit: ")
if char == "e" and char != "c":
    char = ""
    print ("Thank you, bye!")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM