1 #Coding=utf-82name_l = []3passwd_l = []4money_l = []5Goods = {}6index =07 defInput_user ():8 Print("Enter personal information:")9 whileTrue:TenName = input ("Name:") One ifName = ="End it! ": A Break -passwd = input ("passwd:") -Money = Float (input ("Money :")) the name_l.append (name) - passwd_l.append (passwd) - Money_l.append (Money) - + - deflogin (): + Print("Login:") ASUC =False at while notsuc: -Name = input ("Name:") - ifName not inchname_l: - Print("user name does not exist") - Continue -passwd = input ("passwd:") in - GlobalIndex toindex =Name_l.index (name) + ifpasswd = =Passwd_l[index]: - Print("Login Successful") theSUC =True * Else: $ Print("Password Error")Panax Notoginseng - the definput_goods (): + Print("Product:") A whileTrue: theName_goods = input ("Goods_name:") + ifName_goods = ="End it! ": - Break $Price = input ("Price :") $Goods[name_goods] =Int (price) - - definput_buy (): the Print("Purchase:") - whileTrue:WuyiName_goods = input ("Buy_goods_name:") the ifName_goods not inchGoods: - Print("The product does not exist! ") Wu Continue -amount = Int (input ("Amount:")) About ifMoney_l[index] < Goods[name_goods] *Amount: $ Print("Insufficient Balance") - Break - Else: -Money_l[index]-= goods[name_goods] *Amount A Print("Purchase Success","Balance%f"%Money_l[index]) + the - Input_user () $ input_goods () the Login () theInput_buy ()
Simple practical examples of Python lists and dictionaries