Help!: Syntax error, unexpected tEQ


#1



I'm having trouble with my if/elsif/else statement when I compare user input to strings. I'm not sure why I am getting "unexpected tEQ" or why it occurs on the line right before(line 11) and not on line 12 (elsif Galina =="yes" | Kay =="yes"), even if line 11 is blank.

Here is my full code:


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


Error message:

(ruby):11: syntax error, unexpected tEQ
elsif Galina =="yes" | Kay =="yes"


puts "Galina, are you bored? (yes or no) "
Galina = gets.chomp
Galina = Galina.to_s

puts "Kay, are you bored? (yes or no) "
Kay = gets.chomp
Kay = Kay.to_s

if Galina =="yes" && Kay =="yes"
    print "Galina and Kay are both bored :("
    
elsif Galina =="yes" | Kay =="yes"
    print "Galina or Kay is bored :|"
    
else 
    print "Neither Galina nor Kay is bored :D"
end


#2

Probably something codecademy isn't doing quite right when running your code or reporting the error

If I run that locally the result is:

$ xsel -b | ruby  # feed clipboard content into ruby
-:12: syntax error, unexpected ==
elsif Galina =="yes" | Kay =="yes"
                             ^

Same as your error message, it prints out the offending line, but this time with the right line number. The error message is a bit different as well, because this is a later ruby version


#3

Hm, interesting. Any thoughts on how to fix it?


#4

Consider what you were doing and look up the syntax for it. You're already doing something very similar above, which isn't giving you a syntax error.

If you have trouble narrowing down what it is then create a more minimal example, see what you can strip away while keeping the syntax error.


#5

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