How to force user to enter an option / input on prompt?


#1

I would like the prompt to keep looping unless the user gives an answer. Can anyone help? I've tried the following with no success.

unless choice.length > 1
choice = gets.chomp
choice.downcase!
end

I've also tried

while choice.length < 1
choice = gets.chomp
choice.downcase!
end


#2

What are you using, Python, Java?


#3

This is actually Ruby code


#4

Ah, Im no use here. Sorry


#5

Here's a python example that will elaborate in a straightforward way,

ask = input("Keep Looping? ")
while ask != " ":
    print(ask)