Help!: Syntax error, unexpected tEQ


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:

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 :|"
    print "Neither Galina nor Kay is bored :D"


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


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


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.


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