Dec-08-2021, 11:29 AM
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!
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}')