2016-12-16 70 views
0

所以我在卢阿平庸,但我只是用这个亵渎筛选的Lua

local profanitywords = {"fuck", "shit", "ass"} -- a small list 
local input = io.read() 

for i,v in ipairs (profanitywords) do 
    if string.find(input:lower(), v) then 
     print("Profanity") 
    else 
     print("Not Profanity") 
    end 
end 

但我得到的输出打转转是这样的:

Output Image 另外,我使用zerobrane工作室

有时当我输入不同的东西时,它根本不起作用。帮帮我?

+2

你期望输出什么? –

回答

1
local profanity 
for i,v in ipairs (profanitywords) do 
    if string.find(input:lower(), v) then 
     profanity = true 
     break 
    end 
end 

if profanity then 
    print("Profanity") 
else 
    print("Not Profanity") 
end