Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Reference Fixer | Mutable Objects and Function Arguments
Common Python Mistakes and How to Fix Them

bookChallenge: Reference Fixer

Завдання

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}"

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 4
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

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

Свайпніть щоб показати меню

Завдання

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}"

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 4
single

single

some-alt