I'm a little stuck at trying to figure out this python syntax (I know is going to be a super simple fix too). What I want to do is say
if unit is not g, ml, or kg then return a flag. I tried:
if unit != ('g' or 'ml' or 'kg'):
return 1
If unit is set to g, the program doesn't return 1
If unit is set to ml, or kg, the program returns 1.
How do I make it so I can simply, and clearly say to return 1 if unit is not g, ml, or kg?
edit: I know I can do
if unit != 'g':
if unit != 'ml':
if unit != 'kg':
return 1
but this is 3 lines of code where I think 1 line can solve it.