thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

04.04 · Transform and filter values / Practice · 13 min

Standardize names, magnitudes and paired differences

Each input needs its own transformation; the function determines what happens to every item.

Activity 4 of 6 in Transform and filter values

All courses

Python 3: Lists / 04.04

Practice list mapping

Not started

Adapt all three revised source map tasks with predictable inputs.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Rob changes John, JANE and alice into John, Jane and Alice without changing their order.
Rob’s comic strip · Transform and filter values

Your task: three transformations

Keep names as ["John", "JANE", "alice"]. Use map and str.capitalize to produce standard_names as ["John", "Jane", "Alice"]. This is a mechanical case exercise, not a rule for how every person’s name should be written.

Keep signed_numbers as [-5, 3, -1, 9, -2]. Map abs across them and collect magnitudes as [5, 3, 1, 9, 2].

Keep left as [2, 4, 6] and right as [1, 3, 5]. Use map with a two-argument function to produce differences [1, 1, 1]. Print standard_names, magnitudes and differences in that order. Preserve all original lists.

Check the stored lists

The checks inspect output, all source lists and the three stored result lists, not whether map produced them. Review your code for the intended technique. After passing, shorten right to two items and predict how many differences map will produce. Restore the original inputs before checking again.

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

4 steps · Saved work · Instant feedback

YOUR TURN

Apply all three source transformations

Use map to produce standard_names, magnitudes and paired differences. Collect actual lists, preserve every input and print the three results in order.

Expected output
['John', 'Jane', 'Alice']
[5, 3, 1, 9, 2]
[1, 1, 1]

Keep the starting inputs. Print these lines in this order, without extra output.

  • Store the requested names
  • Store the requested signed numbers
  • Store the requested left
  • Store the requested right
  • Store the requested standard names
  • Store the requested magnitudes
  • Store the requested differences
  • Output 1 matches the requested result
  • Output 2 matches the requested result
  • Output 3 matches the requested result

Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Need a nudge?

Pass a callable

Use str.capitalize and abs without calling them first. Wrap the map results in list.

Pair two arguments

The lambda receives one value from left and one from right; subtract the second from the first.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

A mapping can use an existing function or your own expression. Materialize it once, then use the resulting list.