I am new to python and would like to create a Pizza ordering system using python, that looks something like this.
1 Hawaiian $7.50
2 Champagne Ham & Cheese $7.50
3 Beef & Onion $7.50
4 Pepperoni $7.50
5 Simply Cheese $7.50
6 Bacon & Mushroom $7.50
7 Italiano $7.50
8 The Deluxe $13.50
9 Ham, Egg & Hollandaise $13.50
10 Americano $13.50
11 Mr Wedge $13.50
12 BBQ Meatlovers $13.50
I would then like the customer to be able to select different pizzas based on the number so that they don't have to type Hawaiian, they can instead type 1. I have tried both dictionaries and lists but always resulted in this problem:
1 Hawaiian $7.50
2 Champagne Ham & Cheese$7.50
3 Beef & Onion $7.50
4 Pepperoni $7.50
5 Simply Cheese $7.50
6 Bacon & Mushroom $7.50
7 Italiano $7.50
8 The Deluxe $13.50
9 Ham, Egg & Hollandaise $13.50
10 Americano $13.50
11 Mr Wedge $13.50
12 BBQ Meatlovers $13.50
Where the prices would "stick to the pizza name" and the names of pizzas 10 onwards were indented by one character. Manually putting spaces does not seem like the most efficient way of going about my problem. e.g
standardprice = "$7.50"
deluxeprice = "13.50"
print (
"""
1 Hawaiian %s
2 Champagne Ham & Cheese %s
3 Beef & Onion %s
4 Pepperoni %s
5 Simply Cheese %s
6 Bacon & Mushroom %s
7 Italiano %s
8 The Deluxe %s
9 Ham, Egg & Hollandaise %s
10 Americano %s
11 Mr Wedge %s
12 BBQ Meatlovers %s
""" % (standardprice, standardprice, standardprice, standardprice,
standardprice, standardprice, standardprice,deluxeprice,
deluxeprice,deluxeprice, deluxeprice, deluxeprice)
)
Is there an easier way to solve my problem? Also as a side question when printing is there a way that "standardprice" variable applies to the first 7 elements and deluxe price applies to 8-12, rather than the crude way I have done it.
here had a somewhat similar problem but the page did not help.Code Academies "A day at the supermarket tutorial" was not particularly helpful either. I'm very new to python, so explaining like I know nothing would be very helpful