-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Intermediategreat for learninggreat for learningenhancementNew feature or requestNew feature or request
Description
Description
Add a --random flag that displays information for a random Pokémon.
Current Behavior
PyDex only accepts Pokémon names as arguments.
Expected Behavior
When --random is used, PyDex should pick a random Pokémon ID (1-1025) and display its information.
Usage Examples
python pokedex.py --random
python pokedex.py -r # short formImplementation Steps
- Import the
randommodule - Modify the argument parsing to check for
--randomor-r - Generate a random number between 1 and 1025
- Use that number to fetch Pokémon data by ID instead of name
- Update the usage message to show the new option
Skills Required
- Basic Python knowledge
- Understanding of command-line arguments
- Working with random numbers
What You'll Learn
- Command-line argument parsing
- Random number generation
- API usage with different parameters
- Code organization
Testing
Run the command multiple times to ensure you get different Pokémon:
python pokedex.py --randompython pokedex.py -r- Test that it still works with regular Pokémon names
Hints
- Use
random.randint(1, 1025)to generate random numbers - Check if
sys.argv[1]is--randomor-r - The API URL can use either name or ID:
https://pokeapi.co/api/v2/pokemon/25
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Intermediategreat for learninggreat for learningenhancementNew feature or requestNew feature or request