variables - Lua unexpected symbol near '<' -


i'm trying code in lua must 12 years old make print "welcome!". however, whenever run code, error message saying "unexpected symbol near '<'". error message says on line 3. if possible, point out other potential errors in code? first lua code , i'm quite excited. code looks follows:

io.write ("enter age:") age = io.read() if age == <12 print ("o noes, young!") elseif age == >12 print ("o noes, old!") else  print ("welcome, son!") end 

you have unnecessary =='s.

change code to:

io.write ("enter age:") age = io.read() if age < 12 print ("o noes, young!") elseif age > 12 print ("o noes, old!") else  print ("welcome, son!") end 

when checking if variable greater than or less than variable, not need ==.

example: if (7 < 10) then if (9 > 3) then


this may helpful:

as first lua code, may helpful note if checking if variable greater or equal to (or less or equal to) need write as

if (5 >= 5) then if (3 <= 3) then

you need == when checking if equal other variable.

example: if (7 == 7) 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -