1 '' ' 2 for a list of names = [' Golden King angle ',' black girl ',' rain ',' eva ',' naughty ',' silver horn King ',' EVA ',' beheaded '] into the the following operations . 3 . 4 . 5 1. eva returned by the second method names.index () index value . 6 . 7 above 2. list for reversing the form of slices . 8 . 9 3. Print a list of all odd subscripts value of 10 . 11 4 () method to find by eva names.index second value, and it changed the eVA 12 is ' '' 13 is ' '' 14 names = [ 'Golden King angle', 'black girl' ' Rain ',' EVA ',' naughty ',' silver horn king ',' EVA ',' beheaded '] 15 #. 1. 16 # Print (names.index (' EVA ', names.index (' EVA ' ) + 1'd)) . 17 # 2. 18 is # names. reverse() 19 # print(names) 20 . 3 #. 21 is Print (names [. 1 :: 2]) 22 is #. 4. 23 is names [. 6] = names [names.index ( 'EVA', names.index ( 'EVA') +. 1)]. Upper () 24- Print (names) 25 '' ' 26 27 # ##################### cart ############### ####### 28 '' ' 29 to achieve the functional requirements: 30 1. after starting the program, the user enter salary, then enters a loop, and numbered print product 31 is 2 allows the user to select an article number of goods 32 3 after the user selects a product, testing the balance is enough, enough to direct debit, and the shopping cart is not enough to remind balance is less than 33 4, can leave at any time, when you exit, print the purchase of goods and the balance of 34 '' ' 35 36 from the Collections Import Counter 37 [ 38 is goods = [ 39 {"name": "电脑", "price": 1999}, 40 {"name": "鼠标", "price": 10}, 41 {"name": "游艇", "price": 20}, 42 {"name":"Beauty", " . Price " : 9998 }, 43 is ] 44 is 45 # goods_new = {} 46 is V1 = [] 47 names = [] # Name product 48 . Price = [] # commodity prices 1999 10 20 is 9998 49 for I in Range ( . 4 ): 50 for V in goods [I] .values (): 51 is v1.append (V) 52 is # goods_new.setdefault ( "goods" + str (i), v1 ) ?????????? 53 is # Print ( "goods {0: <13}. 1 No {:} ^ 15" .format (I, V)) 54 is for I in V1 [:: 2 ]: 55 names.append (I) 56 is for I in V1 [. 1 :: 2 ]: 57 is price.append (I) 58 # The above product is a data structure 59 the salary = int (INPUT ( " INPUT the salary: " )) # 60 Print ( " product list " .center (60, " * " )) 61 is Print ( " {0: ^ {15}. 1: 2 ^ {32}:>}. 8 (RMB) " .format ( " NUM " , "name " , " . price " )) 62 is for I in Range (. 4 ): 63 is Print ( " {0: ^ {15}. 1: 31 is ^ {2}: ^ 15} " .format (I, names [I], . price [I])) 64 65 # later 66 buy_sign = False 67 buy_car = {} 68 the while Not buy_sign: 69 the try : 70 Choice = iNPUT ( ' enter the number of the item to be purchased, separated by commas: ' ) 71 is NUM = [int (I) forI in choice.split ( ' , ' )] 72 NUM = [I for I in NUM IF I <. 4 ] 73 is num_dic = dict (Counter (NUM)) # the purchase of goods packed into the dictionary number 74 # num_dic the sorted = ( num_dic.items (), key = lambda dic : dic [0]) # is converted into the sorted list 75 cost = 0 76 for K, V in num_dic.items (): 77 Print ( " You have selected product number {0} {1}, {2} is the number of monovalent element is {3} " .format (K, names [K], V,. price [K])) 78 buy_car.setdefault (names [K], " Number: " + STR (V)) 79 # Print ( "buy_car:", buy_car) 80 cost = + V * . price [K] 81 Print ( " Total is: {} yuan, is your salary: element {} " .format (cost, the salary)) 82 83 buy_choice = INPUT ( " Y or Y to confirm the purchase, q or Q to exit: " ) 84 buy_choice = buy_choice.lower () 85 IF buy_choice == ' Y ' : 86 IF cost <= the salary: 87 Print ( " successful purchase balance of {element} " .format (salary- cost)) 88 for K, V in buy_car.items (): 89 Print ( " already purchased 0} {, {}. 1 " .format (K , V)) 90 the else : 91 is Print ( " inadequate wages, reselect " ) 92 num_dic.clear () 93 buy_car.clear () 94 elif buy_choice == ' Q ' : 95 BREAK 96 the else : 97 Print ( " input error " ) 98 99 IF num_dic: 100 buy_sign = True 101 # Print (num_dic) 102 the except a ValueError: 103 Print ( " input error, please try again. " ) 104 # Print (NUM)