dimanche 14 mars 2021

How to create menu in Python for basic POS like system

I'm trying to create a menu for a POS like system. I have my gift card balances with their numbers and I'm trying to incorporate this in a menu. In the menu for example, if a user click the number '1', I want the menu to prompt the user for the gift card number in which they will need to enter the correct gift card number (giftnum1). If the user does not click on a valid number or does not enter the correct gift card, I would like the menu to ask the user to click on a valid number or if the user enters the wrong gift card number, I would like for the menu to ask the user to check the gift card number and try again. I am new at this, so I know that most of my menu code is wrong and could be corrected somehow, but I'm not sure how to do this.

Here is my code that I have:

gift1 = 100
gift2 = 13.50
gift3 = 67.40
giftnum1 = 123456
giftnum2 = 998765
giftnum3 = 456789

print("Here are your current gift cards with the current balances: " + "$" + str(gift1) + " with the gift \ncard number of " + str(giftnum1) + ", $" + str(gift2) + " with a gift card number of " + str(giftnum2) + ", and $" + str(gift3) + " with a gift card number of " + str(giftnum3) + ".")

#making the POS system

def itemmenu():
    print ("Here are the current items with their price. You must choose the correct gift card to go along with the item.")
    print ("1. Nike Shoes ($100)")
    print ("2. Bluetooth Headphones ($67.40)")
    Print ("3. Gloves ($13.50")

loop = True

while loop:
    itemmenu()
    buyitems = input("Enter the number corresponding to the item that you would like to buy.")

    if buyitems == 1:
        print: ("Please enter the correct gift card to buy the Nike Shoes")
        elif buyitems == giftnum1:
            print("You have successfully entered the correct gift card to buy the Nike Shoes, please follow the following directions to be sent a confirmation email.")
        else:
            print("You have not selected a valid item, please try again")
        

Aucun commentaire:

Enregistrer un commentaire