8. Adding an additional if statement re-prompting the user



I completed the Thith Means War section and was curious about the exercises mentioned in the last section.
How would you re-prompt the user if they do not enter anything...

print 'Please type something' 
    user_input = gets.chomp
if user_input.include? "s"
    user_input.gsub!(/s/, "th")
    puts "There are no s's in your string" 

puts "You\'ve been duckified #{user_input}! "


You don't know how many times you will have to re-prompt the user so you should use while or until loop. You can use #empty? to test if string is... empty :slight_smile:

print 'Please type something' 
user_input = gets.chomp

while user_input.empty?
    print 'Empty string? Really? Give me some input!'
    user_input = gets.chomp

print 'Nice input. Thanks.'