Challenge: Reference Fixer
Oppgave
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_listandother_listrefer to the same object. - If they do, create a new list for
target_listthat contains the same elements as before. - Add
itemtotarget_list. - Print both lists using these templates:
"Target list: {target_list}""Other list: {other_list}"
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 4. Kapittel 4
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 5.26
Challenge: Reference Fixer
Sveip for å vise menyen
Oppgave
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_listandother_listrefer to the same object. - If they do, create a new list for
target_listthat contains the same elements as before. - Add
itemtotarget_list. - Print both lists using these templates:
"Target list: {target_list}""Other list: {other_list}"
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 4. Kapittel 4
single