Python Forum
Using 'Or' Operator with If loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using 'Or' Operator with If loop
#1
weight=input("Weight: ")
iweight=float(weight)
kg_lb=input("(L)bs or (K)g: ")
if kg_lb=='L' or  'l':
  iweight=0.4535*iweight
  print(f"You are {iweight} kilos")
elif kg_lb=='K' or 'k':
  iweight=2.2046 * iweight
  print(f"You are {iweight} pounds")
I am new to Python. This is a weight converter program. But the or statement is not working. Can someone please mention the problem with this code.?
buran write Nov-14-2020, 04:42 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
https://python-forum.io/Thread-Multiple-...or-keyword
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020