I'm trying to get the user to put in a specific word.
my code:
import os
os.system("clear")
def get_answer():
print "\nWould you like to 'hit', 'stick', 'double' down or 'split'?"
x = raw_input('> ')
answers = ['hit', 'stick', 'double', 'split']
y = [i for i in answers if i in x]
if y == []:
get_answer()
print y
# exit(0)
return y
def foo():
a = get_answer()
print a
foo()
here's my output if I answer 'hit' the first time;
Would you like to 'hit', 'stick', 'double' down or 'split'?
> hit
['hit']
['hit']
here's my output if I type 'blah' the fist time and then 'hit':
Would you like to 'hit', 'stick', 'double' down or 'split'?
> blah
Would you like to 'hit', 'stick', 'double' down or 'split'?
> hit
['hit']
[]
[]
I don't even really know how to research this. Is it a simple syntax error or is there a deeper issue I just don't understand? I'd love to know how to do this properly.
cmdmodule is probably what you want