0

I am writing a code which takes an input from a user. If the user says yes or yea, then the code will print 'thank you'. But if the user inputs anything else, i.e. 'no', then the code outputs something else.

userinput = input('Have you entered your chosen sentences into UserSentences?:  ')
userinput = str(input)
userinput.lower()
if userinput is('yes') or ('yea'):
    print ('Thank you')
else:
    print('please enter sentences into UserSentences')

But when I input, 'no' the code still returns 'thank you'

Kez
  • 19
  • 1
  • 3
  • I have fixed it, i changed the ('yes') or ('yea'), to ('yes' or 'yea') – Kez Jan 29 '16 at 09:48
  • if userinput in ('yes', 'yea'): – Puffin GDI Jan 29 '16 at 09:48
  • `or ('yea')` will always evaluate to `True` – EdChum Jan 29 '16 at 09:49
  • If you're using python 3 you don't need to use `str` to your `input` becaus it'll be string by default. Also your line with `userinput.lower()` doing nothing because it's not inplace operation. – Anton Protopopov Jan 29 '16 at 09:49
  • doesnt matter, only outputs, prints 'please enter sentences into UserSentences' no matter the input – Kez Jan 29 '16 at 09:50
  • `if userinput == 'yes' or userinput == 'yea':` or `if userinput in ('yes', 'yea'):` – furas Jan 29 '16 at 09:53
  • userinput = raw_input('Have you entered your chosen sentences into UserSentences?: ') userinput.lower() if userinput in ['yes','yea']: print ('Thank you') else: print('please enter sentences into UserSentences') – sudheesh shetty Jan 29 '16 at 10:08

0 Answers0