Python Forum
I freezed - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: I freezed (/thread-7643.html)

Pages: 1 2 3


I freezed - captainflint - Jan-18-2018

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..


RE: I freezed - Larz60+ - Jan-18-2018

you need to put the menu into a function:

like:
def my_menu():
   ...
   return choice
...
choice = my_menu()



RE: I freezed - captainflint - Jan-18-2018

ı could not add definition on my function.its very mixed how ı change my function ?


RE: I freezed - Larz60+ - Jan-18-2018

you don't have any functions. Suggest you read up: https://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html


RE: I freezed - Larz60+ - Jan-21-2018

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


RE: I freezed - captainflint - Jan-21-2018

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]]}
            



RE: I freezed - j.crater - Jan-21-2018

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.


RE: I freezed - captainflint - Jan-21-2018

ı did your suggest.but again it cant Show my inventory?


RE: I freezed - j.crater - Jan-21-2018

Can you post your code attempt? I did a quick check in my Python interpreter (slightly modified for Python 3) and it worked ok.


RE: I freezed - captainflint - Jan-21-2018

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)