Redacted! Second time run, need help


#1



https://www.codecademy.com/courses/learn-ruby/lessons/redacted/exercises/redacted?action=lesson_resume&link_content_target=interstitial_lesson


It looks like you didn't print each word from the user's text to the console.


Replace this line with your code. 
puts "So, what is it you wanna hide?"
text = gets.chomp

puts "And exactly what word do you want to hide?"
redact = gets.chomp

words = text.split " "

words.each do |words|
  if words != redact
    print words + " "
  else
    print "REDACTED "
  end
end

I don't know if its because I worked ahead but I keep getting this error even though it DOES print the words to the console. (Had this same issue the first time I did this project.)


#2

.split() is a string method. Remember the parens.

Edit:

words is the data structure we wish to iterate. The unit component is a word.

words.each do |word|

#3

Now the code works but it says I failed...

puts "So, what is it you wanna hide?"
text = gets.chomp

puts "And exactly what word do you want to hide?"
redact = gets.chomp

words = text.split (" ")

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

My code looks exactly like the example... With the exception of my strings...


#4

Remove the whitespace before (.


#5

Didn't make a change...


#6

Remember to include the space character at the end. "REDACTED ".


#7

I tried that, exact same error message. Is it possible this is a glitch with codecademy?


#8

There seems to be a platform wide glitch that disappears code when we Run it. The workaround I've been using is to click Run, then Refresh immediately. If not checked, click Run again.


#9

Not working :cry:, is their any way to bypass it? (the lesson)


#10

For step 4 you should have only the amount of code expected.

Let's start simple: write an .each loop that goes through words and just prints out each word it finds.

puts "Enter some text"
text = gets.chomp
puts "Word to redact"
redact = gets.chomp
words = text.split(' ')
words.each do |word|
    print word
end

#11

AAUUGGHHHH, that was the problem!

:confounded:


#12

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