Python Forum
If/Else If Statement Not Running
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If/Else If Statement Not Running
#1
Hi,

This is my third post on any sort of coding website and I'm an absolute beginner at programming. I'm going through an online Python tutorial and am working on an exercise that involves writing code to convert the user's weight (input by the user) from pounds to kilograms and vice versa. The user input code I wrote is running without errors but the if and else if statements to convert the weight are not working. I've looked at the solution in the tutorial and can't discern any difference between what I wrote and the answer.

I've provided the code below and also attached a screenshot from PyCharm showing the code and the output that I'm getting. Any help would be greatly appreciated. Thanks!

user_weight = int(input('What is your weight? '))
pounds_or_kilograms = input('Did you enter your weight in pounds or kilograms? ')
if pounds_or_kilograms.lower == "pounds":
     weight_in_kilograms = (user_weight * 0.45359237)
     print('Your weight in kilograms is {weight_in_kilograms}')
elif pounds_or_kilograms.lower == "kilograms":
     weight_in_pounds = (user.weight * 2.2)
     print('Your weight in pounds is {weight_in_pounds}')

Attached Files

Thumbnail(s)
   
Reply


Messages In This Thread
If/Else If Statement Not Running - by new_coder_231013 - Dec-08-2021, 11:29 AM
RE: If/Else If Statement Not Running - by Larz60+ - Dec-08-2021, 03:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Stop if statement from running KieranPage 3 1,968 May-05-2020, 04:10 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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