0

Good day, this is my first post here. I am aware that I am very noobish and it's my first day coding with Python, so if there's any other website for beginners like me that could give me a better advice, I am looking forward to hear it. But if it's not a problem, I would like to ask what is not correct with my code:

weight = int(input("Weight: "))
unit = input("(L)bs or (K)g?: ")

if unit.upper != 'L' or 'K':
    print("Insert correct unit!")
elif unit.upper == 'L':
    converted = weight * 0.45
    print(f' Your weight is: {converted} kg')
elif unit.upper == 'K':
    converted = weight / 0.45
    print(f' Your weight is: {converted} lbs')

I rewrote my code in a few different ways, but still, it ends up returning print("Insert correct unit!") after using every single letter..

I know this code looks pretty basic, but the point for me is to understand why it doesn't work the way I wrote it. I would appreciate any kind of help.

khelwood
  • 55,782
  • 14
  • 81
  • 108
  • You mean `upper()`, instead `upper`, and you mean `not in {'L','K'}`, instead of `!= 'L' or 'K'`. – khelwood Nov 13 '20 at 14:10
  • @khelwood I noticed I've been missing brackets in upper(), but like hell I've had no idea you must write it like this: not in {'L','K'}.. This will help me alot. Thank you! – raverson Nov 13 '20 at 14:31

0 Answers0