Skip to content

Instantly share code, notes, and snippets.

@daniel-schroeder-dev
Created July 24, 2022 22:56
Show Gist options
  • Save daniel-schroeder-dev/1b412f638cf50ea43d726a397b467694 to your computer and use it in GitHub Desktop.
Save daniel-schroeder-dev/1b412f638cf50ea43d726a397b467694 to your computer and use it in GitHub Desktop.
E22 Lesson 5 Idea - Pokemon Catcher
from random import randint, choice
def throw_poke_ball():
return randint(1, 5)
available_pokemon = [
"Pikachu",
"Eevee",
"Snorlax",
"Garchomp",
"Lucario",
"Charizard",
"Gardevoir",
"Ditto",
]
regional_pokedex = []
CAUGHT_POKEMON = 3
username = input("Enter your username: ")
while True:
current_pokemon = choice(available_pokemon)
print(f"You encountered a {current_pokemon}!")
input("Press `Enter` to try to catch the Pokemon!")
poke_ball_result = throw_poke_ball()
if poke_ball_result == CAUGHT_POKEMON:
print(f"You caught the {current_pokemon}!")
regional_pokedex.append(current_pokemon)
available_pokemon.remove(current_pokemon)
else:
print(f"The {current_pokemon} got away!")
if len(available_pokemon) == 0:
print(f"Congratulations {username}! You caught all the Pokemon!")
break
pokemon_left = len(available_pokemon)
print(f"You have {pokemon_left} Pokemon to catch still!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment