2. Setting up


#1



https://www.codecademy.com/courses/ruby-beginner-en-0i8v1/0/2?curriculum_id=5059f8619189a5000201fbcb#


I don't want to write any case like 'add', 'update' and so on. Because it is not the case for this exercise. But my code is always giving "Movie not found". Can you help me?


movies = {
    'leon' => 5,
    'blue is the warmest color' => 5,
    'sing street' => 5
}

puts "What is your choice?"
choice=gets.chomp.downcase

if movies[choice.to_sym].nil?
    puts "Movie is not found"
else
    puts "your choice is #{choice}"
end


#2

It is working now;

movies = {
    'leon' => 5,
    'blue is the warmest color' => 5,
    'sing street' => 5
}

puts "What is your choice?"
choice = gets.chomp

if movies[choice]
    puts "your choice is #{choice}."
else
    puts "Movie is not on the list"
end

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.