python - check user_input with if token in a loop -


i trying write function checks input see whether have entered character '?'.

this got far:

def check_word():    word = []    check = 0    user_input = input('please enter word not contain ?: ')     token in user_input.split():       if token == '?':         print('error') check_word() 

my input: hello?
supposed show 'error'. doesn't show anything. please tell me wrong in code.

i use in operator this

def check_word(s):     if '?' in s:         print('error') 

for example

>>> check_word('foobar') >>> check_word('foo?') error 

Comments