1

I have a solution to use weight_type.upper() but I am still learning and I want to know why [weight_type == 'L' or 'l':] is not giving me the right answer.

weight = input("What is your weight? ")
weight_type = input("Is it in (L)bs or (K)g? ")
if weight_type == 'L' or 'l':
    print(f"Output weight in (K)g is {int(float(weight))*0.453592}")
elif weight_type == "K" or 'k':
    print(f"Output weight in (L)bs is {int(float(weight))*2.20462}")
else:
    print("Unsupported weight type")

Result:

What is your weight? 70
Is it in (L)bs or (K)g? k
Output weight in (K)g is 31.75144

Process finished with exit code 0
  • You should try to tell us what you are doing/trying. You say you are trying to use `weight.upper()`, but what are you trying to accomplish? –  Apr 06 '19 at 03:57
  • 1
    I apologize for incomplete information. My motive is to take in the user input without the limitations of capitalizing the input on the users end, i.e. whether user type "small" L or "capital" L, it should give the appropriate results. – Rahul Kumar Apr 06 '19 at 21:15
  • This is what you did wrong. You basically have to do this for the if: ```if weight_type == "L" or weight_type == "l":```. You have to include it for the second after the or. You typed: ```if weight_type == "L" or "l":```. There is a difference. Hope this helps!!! –  Apr 06 '19 at 21:46
  • Thanks a lot! :) – Rahul Kumar Apr 06 '19 at 23:13
  • no problem^^ glad to help –  Apr 06 '19 at 23:32

0 Answers0