I am really new to coding in general and started Python only recently, and am working on some really beginner practice problems... And I'm working on if and else functions. I followed the tutorial (from yt with exact code) and can't figure out why it won't register correctly.
The practice problem is a simple weight converter from kg to lbs using if and else functions.
weight = int(input("Weight: "))
kg_lbs = input("(K)g or (L)bs?")
converted_one = weight / 0.454
converted = weight * 0.45
if kg_lbs.upper == "K":
print("Weight in lbs: " str(converted_one))
else:
print("Weight in kgs: " str(converted))
When k is entered from input, it is meant to print "Weight in lbs: " str(converted_one)), but it just doesn't register the code and does the else code. And if I remove the else code or replace it w/ something simple such as print("done"), and run it again, it will just continue to skip the if code and do the else code...
The yt video I used for reference is (https://www.youtube.com/watch?v=kqtD5dpn9C8) at 41:00.
CodePudding user response:
As @Larry the Llama says in the comment, upper
is a function, so you need to use it like this:
some_string.upper()