Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Welcome to the Guessing Game! Enter a number!")
- guess = tonumber(read())
- number = math.floor(math.random() * 100)
- count = 1
- while number ~= guess and count < 20 do
- if guess < number then
- print("Your number was too low! Try another number.")
- guess = tonumber(read())
- count=count + 1
- else
- print("Your number was too high! Try another number.")
- guess = tonumber(read())
- count=count + 1
- end
- end
- if count == 20 and guess ~= number then
- print("You lose! The number was " .. number .. "!")
- else
- print("You won! It took you " .. count .. " tries!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement