python-workout icon indicating copy to clipboard operation
python-workout copied to clipboard

Files for the Python Workout book

Results 20 python-workout issues
Sort by recently updated
recently updated
newest added

When I tested with 2 words "python" and "air", the result was: "ythonpay" "iraay" (this is not correct, it should output airway) I think the code should be like this...

https://github.com/reuven/python-workout/blob/d9ec04ca47aa92fa5d013610dd3bd0dbf8903a8f/ch01-numbers/e02b4_sum_intable.py#L20 If I run the function sum_intable() with the input list ['1', '2', '3'] the function will return the TypeError. The is_intable function returns True for each of these input...

https://github.com/reuven/python-workout/blob/d9ec04ca47aa92fa5d013610dd3bd0dbf8903a8f/ch03-lists-tuples/e10b2_sum_numeric.py#L5 def sum_numeric(*items):

The solution in e13b1_namedtuple_records.py throws an error: `KeyError: 'last'` In the solution below: ``` def format_sort_records(list_of_tuples): output = [] template = '{last:10} {first:10} {distance:5.2f}' for person in sorted(list_of_tuples, key=operator.attrgetter('last', 'first')):...

I think it's supposed to be like that ```python if word[0].lower() in 'aeiou': output = f'{word}way' else: output = f'{word[1:]}{word[0]}ay' ```

The problem states: "Ask the user to enter integers, separated by spaces. From this input, create a dict whose keys are the factors for each number, and the values are...

The previous solution only supported int types, resulting in a TypeError when trying to sum other data types, such as lists. This update fixes the issue by allowing mysum_bigger_than to...

Refactored to use slicing and sum() for even/odd indices, making the code shorter, clearer, and matching the problem statement.

Optimisation refractoring, added .lower for potentiel capital letters

Replaced the two-function setup with one clear function (sum_ignore) that directly converts and sums int-compatible values. It now handles both ValueError and TypeError, and avoids using sum as a variable...