Need some assistance with, "Control Flow Know-How"


#1



Control Flow Know-How


Getting the error message, "can't convert String into Array"

Any help is much appreciated.


puts "Type some text here."
text = gets.chomp

puts "What do you want redacted?"
redact = gets.chomp

words = text.split(" ")
words.each do |word|
    if word == redact
        print "REDACTED "
    else 
        print words + " "
    end
end


#2

Your problem is right here,

Your words variable is what you are inside of. Words is text.split(" "). But what do you want to print if a word isn't equal to your redact variable? You want to print the word inside of the string the user gave you. You already set up the do each loop for your list words, but you want to print the word inside of words if it's not the word you want to redact. :slight_smile: Hint: You want to remove the 's' on the end of words in this specific else statement.


#3

Thank you :grinning:


#4

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