text = puts "what do you want printed" text = gets.chomp word = puts "loop" word = gets.chomp re_dact = "nothing to do here" words = text.split(",") words.each do |words| if words == word print "redacted " else print words end
the error is : (ruby):11: syntax error, unexpected $end, expecting keyword_end
You need to end your words.each.
what do you mean by that? i dont understand:confused:
The syntax error is coming from the fact that you started your words.each loop, but you didn't finish it after your if statement. Once you add an
end after the if statement, the syntax error should go away. There's also a few other error that will cause the code to not function right. For example, there is no need to set text to puts "Question." You should just use puts, and then set text to gets.chomp. Also in your else statement, you don't want to print all words. You want to print the word in words that you loop is on.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.