"control flow know-how" need advice here


#1

i've read lots of code in the topics. but still have no idea how to correct my code.
really need help here.
please kindly check my code and tell me how to correct it

puts "please type your keyword"
text=gets.chomp
puts "redact words"
redact=gets.chomp
words=text.split(" ")
words.each do|word|
if word==redact
    print "REDACTED"   
else
print word +" "
end
end

#2

i just saw someone said there was a bug with this exercise here.
anybody help?


#3

Hey samarcici

You just need to change print "REDACTED" to print "REDACTED ", so that it includes the extra space after the print, similar to what you do in the else statement.


#4

thank you for your help. i've already passed this exercise. but i didn't change my code. i don't know what's the reason.