标签:continue append put upper 打印 bsp 名称 class 提示
li= [11,22,33,44,55,66,77,88,99,90] dic ={} l_greater=[] #大于66的所有值列表 l_less=[] #小于66的所有值列表 for i in li: if i == 66:continue if i > 66 : l_greater.append(i) else : l_less.append(i) dic.setdefault(‘k1‘,l_greater) dic.setdefault(‘k2‘,l_less) print(dic)
flag = True while flag: li = ["手机", "电脑", "鼠标垫", "游艇"] for i in li: print(‘{}\t\t{}‘.format(li.index(i)+1,i)) num_of_chioce = input(‘请输入选择的商品序号/输入Q或者q退出程序:‘) if num_of_chioce.isdigit(): num_of_chioce = int(num_of_chioce) if num_of_chioce > 0 and num_of_chioce <= len(li): print(li[num_of_chioce-1]) else:print(‘请输入有效数字‘) elif num_of_chioce.upper() == ‘Q‘:break else:print(‘请输入数字‘)
标签:continue append put upper 打印 bsp 名称 class 提示
原文地址:https://www.cnblogs.com/qingmuzi/p/12630276.html