问题的目的是:
实例化一个名为pokedex
定义一个新函数,该函数将接受pokedex, poke_id, poke_name, poke_type
使用my dictionary函数create_pokemon
并向pokedex
字典添加一个新的key:value
对,其中key
是poke_id
,而value
是新创建的口袋妖怪字典
我创建了一个dictionary函数:create_pokemon(poke_id, poke_name, poke_type)
。键是'hp','defense', 'special_defense'
,列表还在继续
这是我的create_pokemon
函数:
new_pokemon= {
'poke_id': poke_id,
'poke_name': poke_name,
'poke_type': poke_type,
'hp': np.random.randint(400,501),
'attack': np.random.randint(50,101),
'defense': np.random.randint(50,101),
'special_attack' : np.random.randint(100,151),
'special_defense': np.random.randint(100,151),
'speed': np.random.randint(0,101)
}```
so when I display pokedex, it should look something like:
```{1: {'attack': 64,
'defense': 59,
'hp': 495,
'poke_id': 1,
'poke_name': 'charmander',
'poke_type': 'fire',
'special_attack': 100,```
应该这样做,除非我在问题描述中遗漏了什么
相关问题 更多 >
编程相关推荐