Setting Up the 'If' Branch, Part 1(Exercise 4)


#1

Hello everyone I'm new here. First of all thank you codecademy for these useful tutorials for beginners. Now my question:

I don't know what am I doing wrong here but I need help:

print "Please type here your statement"
user_input = gets.chomp.downcase!
if
user_input.include? "s"
print "\(^O^)/"
end

so at the end it says undefined method `include?' for nil:NilClass


#3

ok I corrected myself:

print "Please type here your statement"
user_input = gets.chomp
user_input.downcase!
if
user_input.include? "s"
else
puts "\(^O^)/"
end

like I say there is no better corrector than yourself


#4

I have this same problem, and I more or less want to know WHY it's not allowing me to proceed, despite my code working.

Here it is.

print "Welcome to the S-detector. Enter a string: "
user_input = gets.chomp.downcase!

if user_input.include? ("s" || "S")
    print "This string contains an s or S."
end

Although my S-detector works perfectly, it isn't allowing me to proceed because I apparently forgot "to call .include? on user_input."

I did. It's right there. I don't understand how it could spit out the correct answer otherwise. Maybe I'm rusty jumping back into Ruby, and I just don't see how this is supposed to work...but damn. I want to know what I'm missing.


#5

Put in different lines:

user_input = gets.chomp
user_input.downcase!

you are making the same mistake as I did

I have completed Command Line course and SQL course having previous knowledge of these two and I must say codecademy is good to get into programming language but you really need external sources to enlarge your knowledge, this is not enough. Again they are doing this for free and there are a lot of effort put into these courses but don't expect to work as a professional after completing them.


#6

So what is wrong with this? I'm having issues as well

print "Input Please"
input = gets.chomp
input.downcase!
if input.include? "s"
print "it does"
end