Posted 05 March 2015 - 01:57 PM
I am trying to make a piece of code that takes a string and outputs that string up to where the first vowel is.
For example,
For example,
thumb
Would become:
th
Here is my current code:
first = io.read()
sec = io.read()
vowels = {"a", "e", "i", "o", "u"}
for i =1, string.len(first) do
l = string.sub(first, i, i)
for k, v in pairs(vowels) do
if l == v then
if final ~= nil then --Need this or it will go up to the last vowel
final = string.sub(first, 1, i-1)
end
end
end
end
print(final)
But final is always nil for some reason. Any help?