The full text of this chapter, to read or revisit. To practise, do the exercises.
Exercise 2 — Completing Your Team
You found more Codémon! Add them to your team, but remember: max 6 total.
- Loop through the available Codémon
- Add each one to your team if there's space (max 6)
- Display your complete team
Starter code
my_team = {'Aquachu', 'Pyrochu', 'Florachu'}
available_codemon = ['Zap', 'Rockachu', 'Shadowchu', 'Flame']
Exercise 3 — Removing Banned Codémon
Oh no! The tournament has a banned list. Remove any banned Codémon from your team.
- Remove all banned Codémon from your team
- Verify your team has no banned Codémon
- Display your clean team and verification status
Starter code
my_team = {'Aquachu', 'Pyrochu', 'Florachu', 'Zap', 'Rockachu', 'Shadowchu'}
banned_list = {'Shadowchu', 'Darkmon', 'Glitchmon'}
Exercise 4 — Final Team Validation
Before entering the tournament, verify your team meets all requirements!
- Check and display if team size is valid (between 3 and 6)
- If team has no banned Codémon AND size is valid, display success message
- Otherwise, display which requirement failed
Starter code
my_team = {'Aquachu', 'Pyrochu', 'Florachu', 'Zap', 'Rockachu'}
banned_list = {'Shadowchu', 'Darkmon', 'Glitchmon'}
is_clean = my_team.isdisjoint(banned_list)
print(f"Team is clean: {is_clean}")