Goods=[{" name ":" sweet and sour pork ribs ", "price" : 34, "$"," yuan "},
{" name ":" big chicken ", "price" : 23, "$"," yuan "},
{" name ":" braise in soy sauce meat ", "price" : 65, "$"," yuan "},
{" name ":" mei food braised pork ", "price" : 66, "$"," yuan "}]
Menu_list=[' sweet and sour pork ribs', 'sweet and sour fish', 'big chicken', 'braise in soy sauce meat', 'mei food braised pork]
Order_list=[]
Number=[0] * 7
Price=[34,23,65,66,21]
Menu3=[1. Sweet and sour pork ribs ", "2. Big chicken", "3. Braise in soy sauce meat", "4. Mei food braised pork", "5. Sweet and sour fish]
Sub=0
For I in goods:
Print (I [' name], [' price '], I I [' $'])
While True:
Print (" 1. User order \ n2. Cancel order \ n3. Please make sure the menu or checkout \ n4 interchange hand remnants of digital order ")
Server=int (input (" please select a service: "))
If the server==1:
While True:
Menu_add=input (" please input the name (or number) or input Y the end of the order: ")
If menu_add. Upper ()! :='Y'
Order_list. Append (menu_add)
Print (' point you have to buy the name: {} '. The format (Order_list))
The else: break
If the server==2:
Menu_del=input (" please enter to cancel the name: ")
Order_list. Remove (menu_del)
Print (' : you have some purchase the name 'Order_list)
If the server==3:
While True:
I2=input (" or check-out) : please confirm the name ")
If i2. The lower ()=="checkout" :
Break
Working for the items in goods:
If the items (' name ')==i2:
Name=items (' name ')
If the name in a.k eys () :
A [name] [' number ']=[name] [' number '] a + 1
The else:
A [name]={" number ": 1," unit price ": the items [' price ']}
Print (a)
Total_price=0
For k, v Anderson in tems () :
M=v/' price '
N=v/' number '
All_sum=m * n
Total_price=total_price + all_sum
Print (" please pay ")
Print (total_price)
If the server==4:
For I in range (1, 8) :
Print (" {0} {1} ". The format (menu3] [I - 1, price] [I - 1))
While True:
Print (" order lose 1 ", "cancel lose 2", "check out lost 0")
Sb=int (input ())
If sb==1:
Print (" input menu dishes serial number, commas ")
O=[int (I) for I input in (). The split () ", "]
For I in a:
Number] [I - 1=number] [I - 1 + 1
Sub +=price] [I - 1
For I in range (1, 8) :
If the number [I - 1)!=0:
Print (" {} {} ". The format (menu3] [I - 1, number] [I - 1))
Print (" order together now, "sub)
If sb==2:
Print (" enter the items number you want to withdraw, cancel a few lose a few times ")
H=[int (I) for I input in (). The split () ", "]
For I in h:
Number] [I - 1=number] [I - 1-1
Sub=sub - price] [I - 1
For I in range (1, 8) :
If the number [I - 1)!=0:
Print (" {} {} ". The format (menu3] [I - 1, number] [I - 1))
Print (" order in total now, "sub)
If sb==0:
Print (" please pay ", sub)
This code to achieve order, cancellation, invoicing, now write a piece of code wants to join in, but choose 4 can't implement, strives for the great god help modify, thank you very much, still hope the modified code can inform period, such as the above code is deficiency, could you please help me to modify, thank you
CodePudding user response:
Two days before someone asked [bill] function how to implement theWill you is the same school?
CodePudding user response:
Error message: the list index out of range, it is very clear, you list is beyond the scope of overflow, this solution is very good, where an error you set breakpoints, and see you what are the two menu3 and price list, how many elements; You look at the scope of the for loop 1-8, I it is beyond the scope of the two list, you know how to change (if the code is written by yourself)