![](/img/trans.png)
[英]How do I make it so that the code will ask you your name again if the user answers no after my if statement?
[英]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.