5/6 Please check my code


#1

I'm not sure what I'm entering incorrectly:

puts "Enter text."
text = gets.chomp
puts "Choose something to redact."
redact = gets.chomp

words = text.split(" ")

words.each do |word|
If word == redact
print "REDACTED "
else
print word + " "
end
end


#2

Here is the error I'm getting:

(ruby):10: syntax error, unexpected keyword_else, expecting keyword_end
(ruby):13: syntax error, unexpected keyword_end, expecting $end


#3

You capitalized if. I changed it to lowecase if and it worked fine


#4

It doesn't seem to accept " == " only " = ", might be an error in the tutorial. Here is my code, it worked for me:
puts "Text to search through:"
text=gets.chomp
puts "Word to redact:"
redact=gets.chomp
words=text.split(" ")
words.each do |word|
if words = redact
print "REDACTED"
else
print words + " "
end
end