Posts: 21
Threads: 6
Joined: Jan 2018
Jan-18-2018, 10:45 PM
(This post was last modified: Jan-18-2018, 10:46 PM by captainflint.)
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..
Posts: 11,859
Threads: 472
Joined: Sep 2016
you need to put the menu into a function:
like:
def my_menu():
...
return choice
...
choice = my_menu()
Posts: 21
Threads: 6
Joined: Jan 2018
ı could not add definition on my function.its very mixed how ı change my function ?
Posts: 11,859
Threads: 472
Joined: Sep 2016
Posts: 11,859
Threads: 472
Joined: Sep 2016
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
Posts: 21
Threads: 6
Joined: Jan 2018
Jan-21-2018, 04:39 PM
(This post was last modified: Jan-21-2018, 04:40 PM by captainflint.)
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]]}
Posts: 1,150
Threads: 42
Joined: Sep 2016
Jan-21-2018, 04:55 PM
(This post was last modified: Jan-21-2018, 04:55 PM by j.crater.)
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.
Posts: 21
Threads: 6
Joined: Jan 2018
Jan-21-2018, 05:15 PM
(This post was last modified: Jan-21-2018, 05:20 PM by captainflint.)
ı did your suggest.but again it cant Show my inventory?
Posts: 1,150
Threads: 42
Joined: Sep 2016
Can you post your code attempt? I did a quick check in my Python interpreter (slightly modified for Python 3) and it worked ok.
Posts: 21
Threads: 6
Joined: Jan 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)
|