Description
Refactor the code to use functions for better organization.
Current Behavior
All code is in the main function.
Expected Behavior
Split the code into logical functions.
Suggested Functions
fetch_pokemon_data(name) - Handle API calls
display_pokemon_info(data) - Handle display logic
validate_input(name) - Validate user input
Implementation Steps
- Identify logical sections of the code
- Create functions for each section
- Move code into appropriate functions
- Update the main function to call these functions
- Test that everything still works
Skills Required
- Basic Python knowledge
- Understanding of functions
- Code organization skills
What You'll Learn
- Function design and organization
- Code refactoring
- Separation of concerns
Testing
Test that all functionality still works after refactoring:
python pokedex.py pikachu
python pokedex.py fake-pokemon
python pokedex.py (no arguments)
Hints
- Start with one function at a time
- Make sure each function has a single responsibility
- Test after each function is created
Description
Refactor the code to use functions for better organization.
Current Behavior
All code is in the main function.
Expected Behavior
Split the code into logical functions.
Suggested Functions
fetch_pokemon_data(name)- Handle API callsdisplay_pokemon_info(data)- Handle display logicvalidate_input(name)- Validate user inputImplementation Steps
Skills Required
What You'll Learn
Testing
Test that all functionality still works after refactoring:
python pokedex.py pikachupython pokedex.py fake-pokemonpython pokedex.py(no arguments)Hints