-3

This is practice code of making an invoice containing different commodities where GST is different for each one of the 4 types of pricing of products.

product = input('name product')
price = input('give price')

if product == 'footwear':
    if price <= 500:
        x = 5%        

if (product == 'footwear'):
    if price > 500:
        x = 18% 

if product == 'apparels':
    if price <= 1000:
        x = 5%           

if product == 'apparels':        
    if price <= 1000:
        x = 12%         
        
print('item:', product)
print('price:', price)
print('GST:', price * x)
print('total:', (price * x) + price)

I am just learning, but I don't know why it is showing "Expected expression".

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Gijo Show
  • 1
  • 1
  • Hi there, and welcome to StackOverflow! Just a friendly tip, try to make your question a bit clearer, (that way we will be able to better help you) its kind of confusing right now see also: https://stackoverflow.com/help/how-to-ask – Raed Ali Jan 28 '22 at 11:11

1 Answers1

1

When you write 5%, you are actually using the mod operator which needs a second parameter.

The operator % will return the remainder of the division between 2 numbers. Thus 6%3 will return 0, 7%3 will return 1, 8%3 will return 2, etc.

To save the actual percentage, you can use decimal numbers, like for 5%: 0.05.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Gamopo
  • 1,600
  • 1
  • 14
  • 22