diff --git a/concepts/unpacking-and-multiple-assignment/about.md b/concepts/unpacking-and-multiple-assignment/about.md index e8abaa528d..1cec2f92ec 100644 --- a/concepts/unpacking-and-multiple-assignment/about.md +++ b/concepts/unpacking-and-multiple-assignment/about.md @@ -17,9 +17,9 @@ This is often used in multiple assignment to group all "leftover" elements that It is common in Python to also exploit this unpacking/packing behavior when using or defining functions that take an arbitrary number of positional or keyword arguments. You will often see these "special" parameters defined as `def some_function(*args, **kwargs)` and the "special" arguments used as `some_function(*some_tuple, **some_dict)`. -```exercism/caution +~~~~exercism/caution `*` and `**` should not be confused with `*` and `**`. While `*` and `**` are used for multiplication and exponentiation respectively, `*` and `**` are used as packing and unpacking operators. -``` +~~~~ ## Multiple assignment @@ -69,9 +69,9 @@ Since `tuples` are immutable, you can't swap elements in a `tuple`. ## Unpacking -```exercism/note +~~~~exercism/note The examples below use `lists` but the same concepts apply to `tuples`. -``` +~~~~ In Python, it is possible to [unpack the elements of `list`/`tuple`/`dictionary`][unpacking] into distinct variables. Since values appear within `lists`/`tuples` in a specific order, they are unpacked into variables in the same order: @@ -305,13 +305,13 @@ c = 3 You can also write parameters before `*args` to allow for specific positional arguments. Individual keyword arguments then have to appear before `**kwargs`. -```exercism/caution +~~~~exercism/caution [Arguments have to be structured](https://www.python-engineer.com/courses/advancedpython/18-function-arguments/) like this: `def my_function(, *args, , **kwargs)` If you don't follow this order then you will get an error. -``` +~~~~ ```python >>> def my_function(a, b, *args): diff --git a/concepts/unpacking-and-multiple-assignment/introduction.md b/concepts/unpacking-and-multiple-assignment/introduction.md index a4675a771e..59cab3b4ec 100644 --- a/concepts/unpacking-and-multiple-assignment/introduction.md +++ b/concepts/unpacking-and-multiple-assignment/introduction.md @@ -17,8 +17,8 @@ This is often used in multiple assignment to group all "leftover" elements that It is common in Python to also exploit this unpacking/packing behavior when using or defining functions that take an arbitrary number of positional or keyword arguments. You will often see these "special" parameters defined as `def some_function(*args, **kwargs)` and the "special" arguments used as `some_function(*some_tuple, **some_dict)`. -```exercism/caution +~~~~exercism/caution `*` and `**` should not be confused with `*` and `**`. While `*` and `**` are used for multiplication and exponentiation respectively, `*` and `**` are used as packing and unpacking operators. -``` +~~~~ [multiple assignment]: https://www.geeksforgeeks.org/assigning-multiple-variables-in-one-line-in-python/ diff --git a/exercises/concept/locomotive-engineer/.docs/instructions.md b/exercises/concept/locomotive-engineer/.docs/instructions.md index af914e4924..1d915c143a 100644 --- a/exercises/concept/locomotive-engineer/.docs/instructions.md +++ b/exercises/concept/locomotive-engineer/.docs/instructions.md @@ -4,10 +4,10 @@ Your friend Linus is a Locomotive Engineer who drives cargo trains between citie Although they are amazing at handling trains, they are not amazing at handling logistics or computers. They would like to enlist your programming help organizing train details and correcting mistakes in route data. -```exercism/note +~~~~exercism/note This exercise could easily be solved using slicing, indexing, and various `dict` methods. However, we would like you to practice packing, unpacking, and multiple assignment in solving each of the tasks below. -``` +~~~~ ## 1. Create a list of all wagons @@ -75,9 +75,9 @@ The first `dict` contains the origin and destination cities the train route runs The second `dict` contains other routing details such as train speed, length, or temperature. The function should return a consolidated `dict` with all routing information. -```exercism/note +~~~~exercism/note The second `dict` can contain different/more properties than the ones shown in the example. -``` +~~~~ ```python >>> extend_route_information({"from": "Berlin", "to": "Hamburg"}, {"length": "100", "speed": "50"}) diff --git a/exercises/concept/locomotive-engineer/.docs/introduction.md b/exercises/concept/locomotive-engineer/.docs/introduction.md index e010c07576..66d9ba1581 100644 --- a/exercises/concept/locomotive-engineer/.docs/introduction.md +++ b/exercises/concept/locomotive-engineer/.docs/introduction.md @@ -5,9 +5,9 @@ Unpacked values can then be assigned to variables within the same statement, whi The special operators `*` and `**` are often used in unpacking contexts and with multiple assignment. -```exercism/caution +~~~~exercism/caution `*` and `**` should not be confused with `*` and `**`. While `*` and `**` are used for multiplication and exponentiation respectively, `*` and `**` are used as packing and unpacking operators. -``` +~~~~ ## Multiple assignment @@ -57,9 +57,9 @@ Since `tuples` are immutable, you can't swap elements in a `tuple`. ## Unpacking -```exercism/note +~~~~exercism/note The examples below use `lists` but the same concepts apply to `tuples`. -``` +~~~~ In Python, it is possible to [unpack the elements of `list`/`tuple`/`dictionary`][unpacking] into distinct variables. Since values appear within `lists`/`tuples` in a specific order, they are unpacked into variables in the same order: @@ -293,13 +293,13 @@ c = 3 You can also write parameters before `*args` to allow for specific positional arguments. Individual keyword arguments then have to appear before `**kwargs`. -```exercism/caution +~~~~exercism/caution [Arguments have to be structured](https://www.python-engineer.com/courses/advancedpython/18-function-arguments/) like this: `def my_function(, *args, , **kwargs)` If you don't follow this order then you will get an error. -``` +~~~~ ```python >>> def my_function(a, b, *args):