# 参团import random
hero =['米莱迪','后羿','大乔','刘禅','李元芳']
cantuan =[]# append 加入# random 随机for a inrange(0,100):
num = random.randint(0,4)
cantuan.append(hero[num])print(cantuan)# 代码, 李元芳:13 大乔:16 后羿:33
name ={}for i in cantuan:if i in name:# i英雄名,键 name字典名
name[i]=name[i]+1else:
name[i]=1print(name)
字典 键值对
dictName ={'姓名':'曜','性别':'男','age':18}
hero =['米莱迪','后羿','大乔','刘禅','李元芳']# 增 删 改 查# 1.查print(hero[2])print(dictName['姓名'])# 改
hero[3]='凯'print(hero)
dictName["姓名"]="露娜"print(dictName)# 3.增加:六人局 dead game
hero.append('孙尚香')
dictName['身高']=180print(dictName)print(hero)# 4.删除del hero[5]del dictName['性别']print(hero)print(dictName)# 5。caseprint("东皇太一"in hero)print("姓名"in dictName)
name ={'李元芳':13}
name['李元芳']= name['李元芳']+1print(name['李元芳'])
·```
·
·