I am learning python for the first time(complete beginner) and i have to make this program:
In a store the products have discounts depending on their code:
• The products with code 45612 have 10% discount
• The products with code 45613 have 12% discount
• The products with code 45614 have 18% discount
• The products with code 45615 have 20% discount
Write an algorithm that reads the code (int) and value (float) a product and calculate the price after discount.
If the code you have entered doesn't exist, it should print "The password is not right.
But my program doesn't work, what am i doing wrong?
This is my code:
kodikos = [45612, 45613, 45614, 45615]
password = input("Give code: ")
timi = float(input("Give price: "))
if password == 45612:
timi = timi - 10
print("The price after the discount is %f" %(timi))
if password == 45613:
timi = timi - 12
print("The price after the discount is %f" %(timi))
if password == 45614:
timi = timi - 18
print("The price after the discount is %f" %(timi))
if password == 45615:
timi = timi - 20
print("The price after the discount is %f" %(timi))
for n in kodikos:
if(n != password):
print("The password doesn't exist!")
break