在'<eof>'附近预期'结束''在第3行关闭'而''

mat*_*ing 0 lua

我是Lua的新手,我多次出现这个错误"'结束'预期(关闭'而在第3行')附近''"我已经检查过在网上找到答案但没有运气所以我希望有人可以帮我解决这个问题,非常感谢

这是我的代码:

print ("Welcome to the maze")

while input ~= "leave" do

    print ("What do you want to do first? Leave or inspect?")


    input = io.read()

    if input == "inspect" then
        print (" You venture towards the maze.")
    end

    if input == "leave" then
        print ("You turn around and run.")
    end
Run Code Online (Sandbox Code Playgroud)

M. *_*ena 6

我从未见过lua,但我认为阅读错误将是解决方案:

'结束'预期(在第3行关闭'而')

所以我需要end代码:

print ("Welcome to the maze")

while input ~= "leave" do

    print ("What do you want to do first? Leave or inspect?")

    input = io.read()

    if input == "inspect" then
        print (" You venture towards the maze.")
    end

    if input == "leave" then
        print ("You turn around and run.")
    end

end
Run Code Online (Sandbox Code Playgroud)