lundi 5 avril 2021

SyntaxError: invalid syntax - Python Beginner

I have decided to learn something new during my free time. i am giving Python another go after quitting. I am trying to create a program that covert user body weight in pounds and kilos. I have managed to create successfully if I decide whether is Kg or pounds. however the user to have the ability to chose whether they inputting in KG or Pounds. the first part it works ok. If i choose KG no problem. I get a problem with the elif code is entered. Please see code below, thanks in advance.


choice = input("Do you Want to Calculate in Pounds or KG? ")
if choice == "KG":
  weight_KG = input("What is your Weight in KG? ")
  weight_pounds = float(weight_KG) * 2.204
  print("Your Weight in Pounds is " + str(weight_pounds))
elif choice == "Pounds":
  Pounds_Weight = input("What is your Weight in Pounds? ")
  kg_Weight = float(Pounds_Weight) * 0.45
  print(kg_Weight)
else :
  print("Invalid Value")

Aucun commentaire:

Enregistrer un commentaire