그래서 내 customer_name() 함수를 호출하려고하면 my while 루프를 먼저 호출합니다. 그것은 항상 내 phone_number를 호출하는 것처럼 보입니다. while 루프는 customer_name 루프로갑니다. 그런 다음 while 루프 while phone_number 걸릴 경우 피자 _ 메뉴에 대한 while 루프를 호출합니다. 이 문제를 여러 번 해결하려고했지만 행운이없는 사람이 나를 도울 수 있습니까? 또한 모든 변수 customer_name, phone_number 등을 끝에 인쇄하려고했지만 "정의되지 않음"을 계속해서 제공하여 목록에 모두 추가 한 다음 끝에 인쇄합니다. 누군가가 나를 도울 수 있으면 좋겠어. 정말 고마워. 나는 우리가 아직 그것을 배우지 않았기 때문에 수업 등을 가질 수 없다. 파이썬 3.3내 함수 대신 내 while 루프가 호출됩니다.
premium_pizzas = ["Supreme Cheese", "The Legendary pizza", "Pentakill supreme", "Teeto shroomo supreme", "The volcanic rengar", "Cheese and Ham" , "Vegetriano" ]
gourmet_pizzas = ["Flame Gorilla", "Snazzy chicken", "Intergalactic BBQ", "BBQ Chicken", "Hellfire"]
num_pizzas = -1
def customer_name():
customer_name =""
while customer_name == "":
try:
customer_name = str(input("Please enter your name"))
except:
print("error you must enter something! (cannot be a number)")
else:
user_info()
def delivery_details():
delivery_address = ""
while delivery_address =="":
try:
delivery_address = str(input("please enter your delivery address"))
except:
print("error you must enter something!")
phone_number = 0
while (phone_number <0) or (phone_number <7):
try:
phone_number = int(input("Please enter your phone number:\n\t"))
except:
print("Phone number must be integer only(No only.)")
else:
pizza_list()
def pizza_list():
num_pizzas = -1
while(num_pizzas <= 0) or (num_pizzas > 5):
try:
num_pizzas = int(input('How many pizzas would you like (max of 5):'))
except:
print('Invalid Input')
pizza_dict = {"premium_pizza_price":8.50, "gourmet_pizza_price":5.00, "selected_pizzas":0, "num_premium_pizzas":0, "num_gourmet_pizzas":0}
print('\n==Premium Pizzas==\n')
for i in range (0,len(premium_pizzas)):
print (str(i+1) + '. ' + premium_pizzas[i])
print('\n==Gourmet Pizzas==\n')
for i in range (0,len(gourmet_pizzas)):
print (str(i+1) + '. ' + gourmet_pizzas[i])
print('\nEnter "next" to move on.\n')
while(True):
if(num_pizzas == 0):
break;
try:
selected = input('Select Your Premium Pizza: ')
if(selected == 'next'):
break;
else:
selected = int(selected)
if(selected<=0) or (selected > len(premium_pizzas)):
print('Invalid Input')
else:
pizza_dict['num_premium_pizzas']+=1
num_pizzas -=1
except:
print('Invalid Input')
print(' ')
while(True):
if(num_pizzas == 0):
break;
try:
selected = input('Select Your Gourmet Pizza: ')
if(selected == 'next'):
break;
else:
selected = int(selected)
if(selected<=0) or (selected > len(gourmet_pizzas)):
print('Invalid Input')
else:
pizza_dict['num_gourmet_pizzas']+=1
num_pizzas -=1
except:
print('Invalid Input')
def user_info():
get_user_info = ""
while not get_user_info == "1":
get_user_info =str(input("Press 1 for delivery press\nPress 2 for pickup\n\t:"))
if get_user_info == "1":
delivery_details()
elif get_user_info == "2":
pizza_list()
receipt = [customer_name]
#print('\nTotal number of premium pizzas: ' + str(pizza_dict['num_premium_pizzas']));
#print('Total number of gourmet pizzas: ' + str(pizza_dict['num_gourmet_pizzas']));
#cost = (pizza_dict["num_premium_pizzas"]*pizza_dict['premium_pizza_price'])+(pizza_dict["num_gourmet_pizzas"]*pizza_dict['gourmet_pizza_price']*3.00);
#print('\nTotal cost: ' + str(cost))
customer_name()
#delivery_details()
#geprint('\nTotal number of premium pizzas: ' + str(pizza_dict['num_premium_pizzas']));
들여 쓰기가 잘못되었습니다. 예를 들어, 전화 번호의 'while' 루프는'delivery_details' 함수 외부에 있습니다. 공백은 파이썬에서 중요합니다! – jonrsharpe
오 마이 주! 이것이 문제인지 나는 알 것이다! – user3702248