Skip to content

[Feature] Refactor into Functions #9

@SthembisoMfusi

Description

@SthembisoMfusi

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

  1. Identify logical sections of the code
  2. Create functions for each section
  3. Move code into appropriate functions
  4. Update the main function to call these functions
  5. 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

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions