Can't get past this slide


#1

Section 4 redacted!

Below is what I'm putting in.
message keeps saying: Oops, try again. It looks like you didn't print each word from the user's text to the console.
However each word is showing up in the console.

puts "please input text"
text = gets.chomp
words = text.split(" ")

words.each do |words|
print words + " "
end

puts "word to redact"
redact = gets.chomp


#2

this resolves it:

puts "please input text"
text = gets.chomp
words = text.split(" ")

puts "word to redact"
redact = gets.chomp

words.each do |words|
print words
end

Frankly, this is just rearranging the code and removing the addition of the space after the printing of each word. I'm not sure what I'm to "learn" from rearranging the code so that the instructional slide finds it agreeable. :disappointed:


#3

Hi @bgibson003,

First of all, you are not supposed to add a space while printing those words. It isn't in the instructions.
Secondly, it actually happens the way that the SCT expects the output of:

words.each do |words|
  print words
end

to be on one single line for it to be able to be detected correctly. But, because you puts "word to redact" immediately after it, it becomes something like:

_output_word to redact

on the same line. Thus, it isn't detected. This is just a sort of technical glitch which happens very rarely.

Hope it helps!


#4

Thank you gaurangtandon, that does help. Sorry to be so grumpy, I'm not my own favorite person when I'm frustrated.


#5

No worries :slightly_smiling: And happy coding! :smiley: