Ivan exercise pokemon

mail@pastecode.io avatar
unknown
python
2 years ago
1.0 kB
0
Indexable
Never
ex4 = '''Giving a collection of pokemon cards (i.e. a list) we want to readapt it following the pokemon-evolution rules,
 such that if we have two cards in our deck representing the same pokemon we must replace them with one card 
 representing the evolved version of that pokemon. The evolution rules are defined in the following dictionary:'''
evolution_map = {
    "Poliwag": "Poliwhirl",
    "Bulbasaur": "Ivysaur",
    "Charmander": "Charmeleon",
    "Pidgey": "Pidgeotto",
    "Psyduck": "Golduck",
    "Abra": "Kadabra"
}
"for instance"
l_cards = ["Poliwag", "Pidgey", "Abra", "Pidgey", "Charmander", "Bulbasaur", "Charmander", "Psyduck", "Poliwag","Goldeen"] #what if we add another pidgey to the list?
# The new list should be:
# ['Poliwhirl', 'Charmeleon', 'Bulbasaur', 'Psyduck', 'Pidgeotto', 'Goldeen', 'Abra']
'''Define the function pokemon_cards() which takes a list of pokemon cards
 and returns a new list of pokemon cards which follows the pokemon-evolution rules.'''