Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Reference Fixer | Mutable Objects and Function Arguments
Common Python Mistakes and How to Fix Them

bookChallenge: Reference Fixer

Taak

Swipe to start coding

Complete the function so that you add an item only to the target_list without affecting other_list. Sometimes, both lists may refer to the same underlying object, so be careful to avoid unwanted side effects.

  • Check if target_list and other_list refer to the same object.
  • If they do, create a new list for target_list that contains the same elements as before.
  • Add item to target_list.
  • Print both lists using these templates:
    • "Target list: {target_list}"
    • "Other list: {other_list}"

Oplossing

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 4
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

Awesome!

Completion rate improved to 5.26

bookChallenge: Reference Fixer

Veeg om het menu te tonen

Taak

Swipe to start coding

Complete the function so that you add an item only to the target_list without affecting other_list. Sometimes, both lists may refer to the same underlying object, so be careful to avoid unwanted side effects.

  • Check if target_list and other_list refer to the same object.
  • If they do, create a new list for target_list that contains the same elements as before.
  • Add item to target_list.
  • Print both lists using these templates:
    • "Target list: {target_list}"
    • "Other list: {other_list}"

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 4
single

single

some-alt