在在线编译器中运行良好,但不在终端中运行。蟒蛇

时间:2019-03-19 19:31:32

标签: python-3.x

if flag == True:

    print("congatulations you have guessed number correctly in",7-guesses,"Guesses")

    #if flag is false print sorry

    else:    #error line

        print("Sorry!! you failed to guess number correctly in 7 Guesses")

    #open report.txt in appending mode and write user name and guesses taken

    with open("report.txt", "a") as myfile:

        myfile.write(user_name+"\t"+str(7-guesses)+"\n")

当我在在线编译器上运行此程序时,它工作正常。但是当我在终端中运行此代码时,会说

"File "Hw6.py", line 59
    else:
       ^

SyntaxError: invalid syntax"

有什么主意吗?谢谢

1 个答案:

答案 0 :(得分:0)

您的其他缩进方式不正确

info.plist