Created
August 28, 2017 18:07
-
-
Save therod/f8bfb2d5f7a6aa6200fa02c343fff149 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Please enter a number between 0 and 100" | |
random_number = rand(0..100) | |
guess = gets.chomp.to_i | |
loop do | |
puts "Please enter a positive number" if guess < 0 | |
puts "Please enter a number below 100" if guess > 100 | |
puts "Your number is too low. Try again" if guess < random_number | |
puts "Your number is too high. Try again" if guess > random_number | |
break if guess == random_number | |
guess = gets.chomp.to_i | |
end | |
puts "Yaaay, you won!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment