Hello! So i’ve just started my study (cybersecurity) and i’m having a lot of trouble with Python. I need to make a simple shop that list 8 IT related products, keeps track of the products (how much is left) and tells the user that a product is out of stock and print how much is left. I’m especially having trouble with creating a loop. I def need to learn more but i was hoping i could get some advice. It’s in Dutch so ill translate some important stuff:
voorraad = stock
keuze_klant = choice_customer
Wat wilt u kopen? = what do you want to buy
Dit product hebben we helaas niet meer op voorraad = we dont have that product in stock
Also the code is really messy but again this is my second/third week of having Python so bear with me.
#welkom text + whats in stock
print ("Hallo welkom bij IT4you. De beste ICT specialist van Haarlem!\n")
print("Wij hebben een groot assortiment aan producten:")
print("Computers\n" "Laptops\n" "Processors\n" "Videokaarten\n" "Beeldschermen\n" "Toetsenborden\n" "Koptelefoons\n" "Kabels\n")
stock
computers = 32
laptops = 63
processors = 50
videokaarten = 0
toetsenborden = 84
beeldschermen = 47
koptelefoons = 112
kabels = 225
voorraad = computers, laptops, processors, videokaarten, beeldschermen, koptelefoons, kabels
#stop letter for user
print("Typ q om te stoppen")
while True:
keuze_klant = input ("Wat wilt u kopen? ")
if keuze_klant == ("q"):
print(voorraad)
break
if keuze_klant == "laptop":
laptops -= 1
elif laptops == 0:
print ("Dit product hebben we helaas niet meer op voorraad")
if keuze_klant == "computer":
computers -= 1
elif computers == 0:
print ("Dit product hebben we helaas niet meer op voorraad")
if keuze_klant == "processor":
processors -= 1
elif processors == 0:
print("Dit product hebben we helaas niet meer op voorraad")
if keuze_klant == "videokaart":
videokaarten -= 1
elif videokaarten == 0:
print("Dit product hebben we helaas niet meer op voorraad")
if keuze_klant == "toetsenbord":
toetsenborden -= 1
elif toetsenborden == 0:
print("Dit product hebben we helaas niet meer op voorraad")
if keuze_klant == "koptelefoon":
koptelefoons -= 1
elif koptelefoons == 0:
print("Dit product hebben we helaas niet meer op voorraad")
if keuze_klant == "kabel":
kabels -= 1
elif kabels == 0:
print("Dit product hebben we helaas niet meer op voorraad")
else:
print("Bedankt en tot ziens!")
print("Huidige voorraad: ", voorraad)