By @alesanchezr and other contributors at 4Geeks Academy
Estas instrucciones también están disponibles en Español 🇪🇸
Practice transforming text and data: split and join strings, count characters, remove duplicates with sets, build dictionaries, use list comprehensions, parse simple formats and sort records by several criteria.
This LearnPack is part of a series. We recommend completing them in order:
| # | LearnPack | What you practice |
|---|---|---|
| 1 | Python for Beginners | print, variables, input and basic operations |
| 2 | Python Functions | defining and calling functions, parameters and return |
| 3 | Python Lists and Loops | lists, for/while loops and iteration patterns |
| 4 | Master Python: Functions and Numbers | functions, arithmetic operators, the math module, conditionals and simple loops |
| 5 | Master Python: Strings and Collections (📍 you are here) | strings, lists, tuples, dictionaries, sets, comprehensions and sorting |
| 6 | Master Python: Classes and OOP | classes, special methods, inheritance, properties, composition, dataclasses and iterators |
⬅️ Previous: Master Python: Functions and Numbers
➡️ Next: Master Python: Classes and OOP
Open in Codespaces.
Once VS Code is open, LearnPack should start automatically. If it doesn't, run
learnpack startin the terminal.
-
Install LearnPack, the Python plugin and the testing tools:
npm i @learnpack/learnpack -g && learnpack plugins:install @learnpack/python
pip3 install pytest==6.2.5 pytest-testdox mock- Clone this repository and start the exercises:
git clone https://github.com/4GeeksAcademy/master-python-collections-exercises.git
cd master-python-collections-exercises
learnpack start- Exercises:
001-020 - Focus: string methods,
split()/join(), lists, tuples, dictionaries, sets,*args, list comprehensions, nested lists, parsing text and sorting withsorted()andkey - Difficulty: beginner to intermediate
Each exercise folder contains:
README.md/README.es.md: the instructions (English / Spanish).app.py: the starter file where you write your solution.test.py: the automatic grading tests. You don't need to open it, but you can read it if you are stuck.
Click Run to execute your app.py and Test to grade it.
These exercises were originally part of Master Python. Thanks to Alejandro Sánchez (alesanchezr), Paolo (plucodev), Marco Gómez (marcogonzalo) and every contributor. Found a typo or a bug? Open an issue.