Input response is not working as I expected

28 views Asked by At

I am new to python an I am wondering why my code isn't working.

Here is the code:

print("\n \n Would you like a phone case for your phone? \n \n We have a rubber case for 20 MYR and a carbon fiber case for 100 MYR.")

case = str(input("\n \n Do you want one?")).upper

while (case != "YES" and case != "NO"):
    print("\n Sorry, what do you mean?")
    case = str(input()).upper()

if (case) == ("YES"):
    case = 'yes'
    casetype = str(input("\n \n Which one would you like?")).upper
    if (casetype) == ("RUBBER CASE"):
        casetype = 'rubber case'
        money = money + 20
    if (casetype) == ("CARBON FIBER CASE"):
        casetype = 'carbon fiber case'
        money = money + 100

But the output when I reply 'yes' to when it asks me if I would like a case or not is: "sorry, what do you mean?"

2

There are 2 answers

0
Vasili Syrakis On BEST ANSWER

These lines need to make a function call:

case = str(input("\n \n Do you want one?")).upper
casetype = str(input("\n \n Which one would you like?")).upper

Like this:

case = str(input("\n \n Do you want one?")).upper()
casetype = str(input("\n \n Which one would you like?")).upper()

Otherwise you are storing the str.upper method as a variable

0
orb On

When you call this line:

case = str(input("\n \n Do you want one?")).upper

you're missing the parentheses to turn this into a function call. Try:

case = str(input("\n \n Do you want one?")).upper()

Then your comparison should work.