통화 변환기를 만들려고했으나 옵션 2 또는 3을 선택할 때 "while"루프가 작동하지 않습니다. 옵션 1을 선택하는 것은 좋지만 다른 두 개는 고장났습니다.통화 변환기 문제
##### Welcome Menu######
print("*************************************")
print("* Queensmead currency converter *")
print("* 1) Convert from Pound to Dollar *")
print("* 2) Conver from Dollar to Pound *")
print("* 3) Quit *")
print("* *")
print("*************************************")
print ("Hello, Welcome to the Currency Converter. \nWhat is your name ? ")
name = input()
userChoice= input ("Hi " + name + ", Please choose one of the above options ")
while userChoice == "1":
#Prompt the user the amount of Pound they want to convert
#Store what the user typed into a vairable
userGBP = int(input ("Enter the amount in Pound Stirling you wish to convert to US Dollars: "))
dollar = userGBP * 1.55
#Returns the amount to user request
print ("£",userGBP , "=", dollar ,"US Dollars")
userChoice = input("If you like to convert some more money,please choose from the above Options ")
print (userChoice)
if userChoice =="2":
#Prompt the user the amount of Pound they want to convert
#Store what the user typed into a variable
userDollar = int(input ("Enter the amount in Dollars you wish to convert to Pound Stirling: "))
pound = userDollar * 0.64
#Returns the amount to user request
print ("$",userDollar , "=", pound ,"Pound Stirling")
userChoice = input("If you like to convert some more money,please choose from the above Options ")
print (userChoice)
elif userChoice =="3":
userQuit = input ("")
print ("Thank you for using this program")
else:
print ("Error: You have entered invalid selection. Please try again")
'while' 루프를 사용하여 옵션 "1"을 확인하고'if'를 사용하여 다른 옵션을 확인하는 방법은 무엇입니까? 달러를 파운드로 변환하는 것이 개념적으로 매우 다르므로 다른 구조가 필요합니까? 인터넷상의 튜토리얼에서'while'과'if' 문에 대한 섹션을 읽어보십시오. 여러분은 실수를 이해할 것입니다.이 구현은별로 의미가 없으며 다른 많은 문제가 있습니다. – BartoszKP
이 질문은 통화 변환에 관한 것이 아닙니다. –