Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I freezed
#1
Sad 
message="***Welcome to Sehir Online Market***"
message2="Please log in by providing your user credentials:"
print message,('\n'),message2
users={"ahmet":"sehir123","meryem":"4444"}
login=raw_input("Username: ")
password=raw_input("Password: ")
while True:
    if (users)[login]==(password):
        print 'Succesfully loged in !'
    else:
        print "Your user name and/or password is not correct. Please try again!"
        break
    if True:
        print "Welcome, ahmet! Please choose one of the following options by entering the corresponding menu number."
        break
message3="Please choose one of the following Services:"
select=True
while select:
    print("""
1. Search for a product
2. See Basket
3. Check Out
4. Logout
5. Exit
0. Return The Menu    
""")
    break
select=raw_input("Your Choice: ")
message4=raw_input("What are you searching for: ")
if select=="1":

    if message4=="Juice" or "juice":
            print "found 3 similar items:"
            print("""
            1.grape juice $9
            2.orange juice $8
            3.apple juice $7     
            """)
            message5=raw_input("Please select which item you want to add to your basket (Enter 0 for main menu):")




            if message4=="3":
                message6=raw_input("Adding apple juice. Enter Amount: ")
                if message6=="2":
                    warning="Added apple juice into your Basket"
                    warning2="Going back to menu..."
                    print warning,('\n'),warning2
            elif select=="0":
                print select
ı can t return menü.how ı do it ? thanks..
Reply
#2
you need to put the menu into a function:

like:
def my_menu():
   ...
   return choice
...
choice = my_menu()
Reply
#3
ı could not add definition on my function.its very mixed how ı change my function ?
Reply
#4
you don't have any functions. Suggest you read up: https://anh.cs.luc.edu/python/hands-on/3...tions.html
Reply
#5
Do not use PM to ask for assistance. Ask your questions here so others can benefit
from them.
I will not respond to 'buddy' requests
Reply
#6
okey sorry ı did'nt know that.I have to create inventory and ı must use dictionary.When ı select 1 in the menü program must give me products list.such that;

inventory = {'asparagus': [10, 5], 'broccoli': [15, 6], 'carrots': [18, 7],
'apples': [20, 5], 'banana': [10, 8], 'berries': [30, 3],
'eggs': [50, 2], 'mixed fruit juice': [0, 8], 'fish sticks': [25, 12],
'ice cream': [32, 6],'apple juice': [40, 7], 'orange juice': [30, 8],'grape juice': [10, 9]]}

How ı do it ?


menu=True
while menu:
        print("""
                    1.Search for a product.
                    2.See Basket
                    3.Check Out
                    4.Logout
                    5.Exit
                    """)
        answer = raw_input("Your choice: ")

        message2 = "Please choose one of the following Services:"
        print message2
        if menu=="1":
            inventory = {'asparagus': [10, 5], 'broccoli': [15, 6], 'carrots': [18, 7],
                         'apples': [20, 5], 'banana': [10, 8], 'berries': [30, 3],
                         'eggs': [50, 2], 'mixed fruit juice': [0, 8], 'fish sticks': [25, 12],
                         'ice cream': [32, 6],'apple juice': [40, 7], 'orange juice': [30, 8],'grape juice': [10, 9]]}
            
Reply
#7
You can print "inventory" dictionary like any other variable. Do you require it to be formatted in a specific way?
I think that you want "menu" in line 14 if statement to be "answer" instead.
Reply
#8
ı did your suggest.but again it cant Show my inventory?
Reply
#9
Can you post your code attempt? I did a quick check in my Python interpreter (slightly modified for Python 3) and it worked ok.
Reply
#10
That's code.I printed inventory but ı need in the question of 'What are you searching for:" when ı search juice program must give me only juices.How ı supply it ?

users={"meryem":"4444","ahmet":"sehir123"}
login=raw_input("Username: ")


if login in users:
    psw=raw_input('Password: ')
    if users[login]==psw:
        print('Successfully logged in!'),('\n'),"Welcome, meryem! Please choose one of the following options by entering the corresponding menu number."

    else:
        print('Your user name and/or password is not correct. Please try again!')
else:
    print "Your user name and/or password is not correct. Please try again!"


menu=True
while menu:
    print ("""
                                1.Search for a product.
                                2.See Basket
                                3.Check Out
                                4.Logout
                                5.Exit
                                """)
    answer = raw_input("Your choice: ")


    if answer=="1":
                        inventory = {'asparagus': [10, 5], 'broccoli': [15, 6], 'carrots': [18, 7],
                         'apples': [20, 5], 'banana': [10, 8], 'berries': [30, 3],
                         'eggs': [50, 2], 'mixed fruit juice': [0, 8], 'fish sticks': [25, 12],
                         'ice cream': [32, 6], 'apple juice': [40, 7], 'orange juice': [30, 8],
                         'grape juice': [10, 9]}
                        message3=raw_input("What are you searching for: ")
                        for message3 in [inventory]:
                            print(message3)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020