So far in the course every variable has held a single value. Lists change that — a list is an ordered collection that can hold as many values as you need, all under one variable name. You can read individual items by their position, add new items to the end, and remove items you no longer need, all with built-in Python syntax. This page also covers the three main ways to format output withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/marioaje/Python/llms.txt
Use this file to discover all available pages before exploring further.
print(), which you will use constantly as you build programs.
Section 1 — Lists
Creating a List
A list is written with square brackets[], and its items are separated by commas. The list below — taken directly from the course — mixes strings, an integer, a float, and a boolean all in the same collection:
Python lists can hold values of different types at the same time. A single list can contain strings, integers, floats, and booleans side by side — there is no requirement that all items share the same type.
semana1/listadedatos.py
Index Reference
Each item in the list occupies a numbered index, starting at0:
| Index | Value | Type |
|---|---|---|
0 | 'mario' | str |
1 | "Jimenez" | str |
2 | 44 | int |
3 | 10.1 | float |
4 | True | bool |
Reading and Updating Items
Pass the index inside square brackets to read or overwrite any item:semana1/listadedatos.py
Adding and Removing Items
semana1/listadedatos.py
.append(value)
Adds
value to the end of the list. The list grows by one element..pop()
Removes and returns the last element. The list shrinks by one element.
Full Program
Here is the completelistadedatos.py as a single runnable block:
semana1/listadedatos.py
Section 2 — Print Formatting
The course filepersonalizacionprint.py demonstrates three different ways to combine variables into a single line of output. All three approaches produce a readable result — understanding when to use each one makes your code cleaner.
semana1/personalizacionprint.py
When to Use Each Approach
| Approach | Best when… |
|---|---|
+ concatenation | You need precise control over separators or special characters between values |
+ ' ' + space | You want a simple space and are working with strings only |
print(a, b, ...) | You have multiple values and want Python to handle spacing automatically — also works with non-string types without needing explicit conversion |
The
+ operator requires both sides to be strings. If you try to concatenate a string and an integer with + you will get a TypeError. Using multiple comma-separated arguments to print() avoids this — Python converts each argument to a string automatically before printing.