'Expected an indented block' 错误
'Expected an indented block' Error
#define welcome as the main menu page for editing editing details.
def welcome():
print ('Welcome to SUNI-DAYS VILLA \n \nPlease choose to edit from the following:\n\n1-Personal Details\n2-Holiday Option\n3-Villa Options\n4-Additional Options\n\n0-Exit')
('\n')
main_option = input ('Option:')
#After choosing option, run their choice
if main_option ==('1'):
cust_opt()
if main_option ==('2'):
holiday_opt()
if main_option ==('3'):
villa_opt()
if main_option ==('4'):
add_opt()
if main_option ==('0'):
quit()
elif print ('Please choose a valid option:'):
welcome()
#Option 1- from welcome()
def cust_opt():
print ('Please answer ALL of the questions')
cust_title = input ('Choose an option:\n1-Mr\n2-Mrs\n3-Miss\n4-Ms\nTitle:')
if cust_title ==('1'):
cust_title1 ==('Mr')
if cust_title ==('2'):
cust_title1 ==('Mrs')
if cust_title ==('3'):
cust_title1 ==('Miss')
if cust_title ==('4'):
cust_title1 ==('Ms')
elif print ('Please choose your title')
cust_name = input ('Full Name:')
cust_age = input ('Age:')
cust_dono = input ('Door/Flat number:')
cust_str = input ('Street Name:')
cust_city = input ('City:')
cust_post = input ('Postcode:')
print(cus_title1 , cust_name, \ncust_age 'years old.',\n'Address:' , cust_dono, cust_str, \ncust_city, \ncust_post)
'Expected an indented block' 'welcome()' 后报错
有点糟透了,因为我刚开始学习它,而且我已经开始思考了。
所以我用 def 写了一堆函数然后 运行 我做了 'welcome()'
.. 这不是我应该做的吗
如错误所述 - 您的缩进已关闭。 Indentation is very important in Python.
您可能还想 use a while
loop for validating input。
def welcome():
# ...
else:
print ('Please choose a valid option:')
return
welcome()
def cust_opt():
# ...
else:
print ('Please choose your title')
# ...
return
#define welcome as the main menu page for editing editing details.
def welcome():
print ('Welcome to SUNI-DAYS VILLA \n \nPlease choose to edit from the following:\n\n1-Personal Details\n2-Holiday Option\n3-Villa Options\n4-Additional Options\n\n0-Exit')
('\n')
main_option = input ('Option:')
#After choosing option, run their choice
if main_option ==('1'):
cust_opt()
if main_option ==('2'):
holiday_opt()
if main_option ==('3'):
villa_opt()
if main_option ==('4'):
add_opt()
if main_option ==('0'):
quit()
elif print ('Please choose a valid option:'):
welcome()
#Option 1- from welcome()
def cust_opt():
print ('Please answer ALL of the questions')
cust_title = input ('Choose an option:\n1-Mr\n2-Mrs\n3-Miss\n4-Ms\nTitle:')
if cust_title ==('1'):
cust_title1 ==('Mr')
if cust_title ==('2'):
cust_title1 ==('Mrs')
if cust_title ==('3'):
cust_title1 ==('Miss')
if cust_title ==('4'):
cust_title1 ==('Ms')
elif print ('Please choose your title')
cust_name = input ('Full Name:')
cust_age = input ('Age:')
cust_dono = input ('Door/Flat number:')
cust_str = input ('Street Name:')
cust_city = input ('City:')
cust_post = input ('Postcode:')
print(cus_title1 , cust_name, \ncust_age 'years old.',\n'Address:' , cust_dono, cust_str, \ncust_city, \ncust_post)
'Expected an indented block' 'welcome()' 后报错 有点糟透了,因为我刚开始学习它,而且我已经开始思考了。 所以我用 def 写了一堆函数然后 运行 我做了 'welcome()' .. 这不是我应该做的吗
如错误所述 - 您的缩进已关闭。 Indentation is very important in Python.
您可能还想 use a while
loop for validating input。
def welcome():
# ...
else:
print ('Please choose a valid option:')
return
welcome()
def cust_opt():
# ...
else:
print ('Please choose your title')
# ...
return