why does this if-statement not work? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: why does this if-statement not work? (/thread-22505.html) |
why does this if-statement not work? - sandeen - Nov-15-2019 Hello, I am the biggest noob in this forum probably, so my first question is why this simple if-statement allways accepts the first if-statement regardless of what i put in to the 'unit' variable? weight = float(input(f'Weight: ')) unit = input('[L]bs or [K]g: ').lower() if unit == 'k' or 'kg': print(f'weight is {weight / 0.45} pounds') elif unit == 'l' or 'lbs': print(f'weight is {weight * 0.45} kg') else: print('Invalid unit of measurement')thx RE: why does this if-statement not work? - buran - Nov-15-2019 https://python-forum.io/Thread-Multiple-expressions-with-or-keyword RE: why does this if-statement not work? - sandeen - Nov-15-2019 (Nov-15-2019, 03:07 PM)buran Wrote: https://python-forum.io/Thread-Multiple-expressions-with-or-keywordThank you, that explained it well! |