Feb-03-2018, 01:01 PM
(This post was last modified: Feb-03-2018, 01:01 PM by captainflint.)
(Feb-03-2018, 06:12 AM)ka06059 Wrote:class userpass: users = {"meryem":"4444","ahmet":"sehir123","gakkos":"2323"} 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]} market_inventory = [] customers_basket = [] def login(self): while True: #added login = raw_input('Username:') if login in self.users.keys(): psw = raw_input('Password:') if self.users[login] == psw: print 'Successfully logged in!','\n','Welcome,',login,"Please choose one of the following options by entering the corresponding menu number." break #added 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!"recapping/learning while providing solution , wont mind if someone will correct me, i appreciate that.
Output:>>> log = userpass() >>> log.login() Username:gakkos Password:2323 Successfully logged in! Welcome, gakkos Please choose one of the following options by entering the corresponding menu number. >>>
i assume you hv done this in python 2.x (raw_input function available) so i left out the brackets in print statement.
i added while and break statement so the code will keep asking for correct username & password
thanks a lot my friend it Works :))
if I don't understand somewhere could ı ask you ?
that is normal
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": message3=raw_input("Please select which item you want to add to your basket (Enter 0 for main menu): ") for key,value in inventory.items(): if key in inventory.items(): print "found",value,"similar items" elif message3 in key: print key, ":", valueı have to create menü but it can't see my code. ı changed little bit but doesn't work when ı change item in inventory program can not add basket when ı chhose 2 in menü.