mercredi 5 août 2020

Python ignores "if" statement, a possible scope problem? [closed]

I'm trying to write a weight converter which splits the given input and act accordingly however if statement is completely ignored. So far my search revealed that it might be a scope problem but I'm pretty green so couldn't apply any solutions to my specific code.

def weight_convert(answer):
      seperated = answer.split(" ")
      unit = seperated[1]
      weight = int(seperated[0])
      if unit.lower == "lbs":
         converted = weight * 0.45
      else:
         converted = weight % 0.45
      return converted, unit

Aucun commentaire:

Enregistrer un commentaire