Skip to content

Instantly share code, notes, and snippets.

@kurzweil777
Created June 18, 2020 11:43
Show Gist options
  • Save kurzweil777/38a1f85b20118530ddd07078c614e8d5 to your computer and use it in GitHub Desktop.
Save kurzweil777/38a1f85b20118530ddd07078c614e8d5 to your computer and use it in GitHub Desktop.
Exercise from code_wars
class PokeScan:
"""The task: https://bit.ly/3hycrA2"""
characters = {"water": "wet", "fire": "fiery", "grass": "grassy"}
def __init__(self, name, level, pkmntype):
self.name = name
self.level = level
self.pkmntype = pkmntype
if level in range(0, 21) or level < 0:
self.level_character = "weak"
elif level in range(21, 51):
self.level_character = "fair"
else:
self.level_character = "strong"
def info(self):
return f'{self.name}, a {"".join([self.characters[poke] for poke in self.pkmntype.split()])} ' \
f'and {self.level_character} Pokemon'
pikachu = PokeScan("Pikachu", 50, "grass")
print(pikachu.info()) # Pikachu, a grassy and fair Pokemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment