标签:三级 items center ping first 中兴 苹果 user 儿童
menu = { ‘手机数码‘:{‘手机‘:[‘华为‘,‘中兴‘,‘苹果‘],‘数码‘:[‘相机‘,‘电脑‘]}, ‘图书‘:{‘儿童‘:[‘连环画‘,‘童话‘],‘成人‘:[‘体育类‘,‘养生类‘]}, ‘家电‘:{‘厨房‘:[‘电磁炉‘,‘电饭煲‘],‘客厅‘:[‘洗衣机‘,‘冰箱‘,‘电视‘]} } shopping_cart = [] print(‘Products list‘.center(40, ‘*‘)) i = 0 temp_menu = [] for first_menu,v in menu.items(): temp_menu.append(first_menu) print(i,‘.‘,first_menu) i += 1 user_choice = input(‘What do you want to buy?:‘) if user_choice.isdigit(): user_choice = int(user_choice) if user_choice < len(menu): item2 = menu[temp_menu[user_choice]] a = 0 temp_menu2 = [] for second_menu, v in item2.items(): temp_menu2.append(second_menu) print(a, ‘.‘, second_menu) a += 1 user_choice2 = input(‘What do you want to buy?:‘) if user_choice2.isdigit(): user_choice2 = int(user_choice2) if user_choice2 < len(item2): item3 = item2[temp_menu2[user_choice2]] b = 0 for third_menu in item3: print(b, ‘.‘, third_menu) b += 1 user_choice3 = input(‘What do you want to buy?:‘) if user_choice3.isdigit(): user_choice3 = int(user_choice3) if user_choice3 < len(item3): product = item3[user_choice3] shopping_cart.append(product) print("[%s] have been put into your shopping cart."%product) else: print("There doesn‘t have it. ") else: print(‘Invaild data type...‘) else: print("There doesn‘t have it. ") else: print(‘Invaild data type...‘) else: print("There doesn‘t have it. ") else: print(‘Invaild data type...‘)
标签:三级 items center ping first 中兴 苹果 user 儿童
原文地址:https://www.cnblogs.com/charliedaifu/p/10090203.html