'期望缩进的块'错误

时间:2016-02-11 18:02:02

标签: python function block

#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)

'期待一个缩进的块'在' welcome()'之后给出错误 有点糟透了,因为我刚开始学习它,我已经精神状态了。 所以我用def写了一堆函数,然后运行它我做了'欢迎()' ..不是我想做的事情

1 个答案:

答案 0 :(得分:0)

就像错误一样 - 你的缩进是关闭的。 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