0

I have a code that has somebody input one of the first five elements on the periodic table and I need a way to say if the input is not in the list. I have this so far but it says it is wrong every time (Work is the input variable):

if (work is not 'H','He','Li','Be',"B"):
    print ("That is not in the list of elements. Try again.")
Jack Bay
  • 17
  • 3

1 Answers1

1

Assuming that the input variable work is correct (with no extra whitespace, etc.) , this is how we use the in operator:

if work not in ('H', 'He', 'Li', 'Be', 'B'):
    print('That is not in the list of elements. Try again.')
Óscar López
  • 232,561
  • 37
  • 312
  • 386