Python:语法错误IF Else语句

时间:2018-05-08 07:04:08

标签: python-3.x

基本上在我的代码底部使用

if size == 1:
while L == y:
    name = input('apllicant: ')
    numeral = int(input('dollars: '))
    location = input('North or South location: ')
    if location == 'North' or 'South':
        print('Thank You!\n')
        calculate()
        L = input('Do you want to log another (y/n)? '
    else:
        location = input('North or South : ')
else:
     L = input('Do you want to log another (y/n)? ')

我在第10行用else语句得到语法错误,我不知道为什么会一直发生。

2 个答案:

答案 0 :(得分:1)

你需要在if子句后添加制表符.if ... else语句的语法是: if expression: statement(s) .... else: statement(s)

答案 1 :(得分:0)

我更正了一些识别错误和第9行的括号

if size == 1:
    while L == y:
        name = input('apllicant: ')
        numeral = int(input('dollars: '))
        location = input('North or South location: ')
        if location == 'North' or 'South':
            print('Thank You!\n')
            calculate()
            loan = input('Do you want to log another (y/n)? ')
        else:
            location = input('North or South : ')
else:
    loan = input('Do you want to log another (y/n)? ')