Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Elif statmenet in Python issue

What I have tried:

I am following an example code to do an Elif statement:

amount = int(input("Enter amount: "))

if amount<1000:
discount = amount*0.05
print ("Discount",discount)
else:
discount = amount*0.10
print ("Discount",discount)

print ("Net payable:",amount-discount)

However when I type the first line of code in
Instead of being able to type the second line in which begins with the if statement
I get asked the questions as if I was the user which appears like this

amount = int(input("Enter amount: "))
Enter amount:

There is something wrong, please I need guidance.
Posted
Updated 26-Mar-18 18:37pm

1 solution

amount = int(input("Enter amount: "))

if amount < 1000:
    discount = amount*0.05
    print("Discount", discount)
else:
    discount = amount*0.10
    print("Discount", discount)

print("Net payable:", amount-discount)



There isn't anything particularly wrong with the code itself from what I can see unless you aren't using white space. Something that could be wrong is that you're not actually editing a python file. From what you've said do you happen to be in the python IDLE shell?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900