Playing around with loops at the end


#1

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

I'm trying to limit the values that a user puts in when giving a rating. I can't seem to get my code to work though. I keep getting this once I click save and submit:

(ruby):60: warning: string literal in condition

I know there's something wrong with the while loop I added in because once I take it out, it works.

Below is my code:

when "add" 
    puts "Which movie would you like to add?"
    title = gets.chomp
        if movies[title.to_sym].nil? 
            puts "How would you rate the movie from a scale of 1 to 5?"
            rating = gets.chomp
                while rating != ("1" || "2" | "3" || "4" || "5")
                    puts "Error! Please enter a number from 1 to 5."
                    rating = gets.chomp 
                end
            movies[title.to_sym] = rating.to_i
            puts "#{title} has been added with a rating of #{rating}!"
        else
            puts "#{title} has already been added before."
            puts "Type 'add' if you still want to add a movie."
            choice = gets.chomp
        end


Thanks all. :slight_smile:


#2

This post was flagged by the community and is temporarily hidden.


#3

I still get the same error. :sweat:


#4

This post was flagged by the community and is temporarily hidden.