Hello i am just getting into ruby and i need help with this task. The task is to enter the 7 days of the week in a hash like this {"Monday" => 1 , "Tuesday" =>2 ..etc} And when a user inputs a number between 1-7 it shows the corresponding day. So if the user presses 5 , it outputs "Friday". So far i have come up with this:
puts "Enter Number"
hash = {"Monday"=>1,"Tuesday"=>2,"Wednesday"=>3,"Thursday"=>4,"Friday"=>5,"Saturday"=>6,"Sunday"=>7}
hash.each do |x,y|
input = gets.to_i
print x if input == y
end