1/6 bug/error


#1

In the beginning of this lesson I was just trying to see if I could see what was happening because a couple of different ways would produce me different results maybe Im doing it wrong but isn't the first prompt what its supposed to search through, and then what to "redact".This is what I got and passed.

Text to search through:
Daniel Ortega is a threat and an asset.
Word to redact:
Daniel Ortega
Daniel Ortega is a threat and an asset. ["Daniel", "Ortega", "is", "a", "threat", "and", "an", "asset."]


#2

We will need to see your code. Your redact should be a single word in this case. Multiple words are not expected except as a challenge in the last lesson for the learner to carry on with on their own.


#3

This was from the example given I didn't modify the code. It was the completed lesson program. But yes when I tried it over again this time with one word only and did work and showed the "REDACTED" an the array that it makes it into.

puts "Text to search through: "
text = gets.chomp
puts "Word to redact: "
redact = gets.chomp

words = text.split(" ")

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

I also tried it, while accidently holding shift and got a different outcome also.

Text to search through:
Daniel is studying programming and information system security along with IoT.
Word to redact:
Daniel

REDACTED is studying programming and information system security along with IoT. ["Daniel", "is", "studying", "programming", "and", "information", "system", "security", "along", "with", "IoT."]

and this gave me an error from code academy saying it was an infinite loop. I think I'm breaking something that I shouldn't be or just making it way harder on myself lol. thanks for the quick response.


#4

Sorry, I didn't look at the actual lesson. Without a link it's a total pain to find the correct exercise. Post a link to the ex. so I can test your code.

The code looks fine and I don't see how an infinite loop could get in there, but let's see?


#5

Sure no problem.

https://www.codecademy.com/en/courses/ruby-beginner-en-mzrZ6/0/1?curriculum_id=5059f8619189a5000201fbcb

It was after I typed the hash or array of text, I hit enter;
then prompts redact what?
I put in the single word held shift pressed enter and made another blank line in the terminal, I let go of shift after noticing that and that error pops out was able to reproduce it.
Might just be a bug. Im still learning Ruby by the way if that changes anything.


#6

Actually, it is probably not a bug but just the way Ruby handles input. It may not be able to process multiline, and is getting hooped by a missing EOF or some such thing.


#7

puts "Text to search through: "
text = gets.chomp
puts "Word to redact: "
redact = gets.chomp

words = text.split(" ")

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

Code runs fine.


#8

OK yeah it is working but yeah I don't understand to much Ruby to know EOF errors but yes must have been user error.

Thanks for you time.