Python Forum
why does this if-statement not work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why does this if-statement not work?
#1
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
Reply


Messages In This Thread
why does this if-statement not work? - by sandeen - Nov-15-2019, 03:05 PM
RE: why does this if-statement not work? - by buran - Nov-15-2019, 03:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  getting an import statement to work in my program barryjo 1 1,690 Dec-06-2021, 04:28 PM
Last Post: snippsat
  Why doesn't this print statement work? stylingpat 10 5,842 Mar-23-2021, 07:54 PM
Last Post: buran
  return statement will not work TheTechRobo 2 2,659 Mar-30-2020, 06:22 PM
Last Post: TheTechRobo
  Newbie to Python Why does this if statement not work? Wrightys99 5 2,643 Mar-26-2020, 12:04 PM
Last Post: buran
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 3,246 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619
  Python if statement docx wount work Selfiatus1 5 3,158 Jun-07-2019, 11:44 PM
Last Post: Larz60+
  Simple If Statement doesn't work Jack_Sparrow 3 3,466 May-14-2018, 09:37 AM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

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