2016-12-16 55 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