Challenge: Temporary List Modification
Завдання
Swipe to start coding
Create a generator-based context manager using contextlib.contextmanager that temporarily appends an item to a given list when entering the context and removes it when exiting the context.
- The context manager must append
itemto the end oflstwhen entering the context. - The context manager must remove the last occurrence of
itemfromlstwhen exiting the context. - The context manager must restore the list to its previous state if an exception occurs inside the context.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 3. Розділ 3
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 8.33
Challenge: Temporary List Modification
Свайпніть щоб показати меню
Завдання
Swipe to start coding
Create a generator-based context manager using contextlib.contextmanager that temporarily appends an item to a given list when entering the context and removes it when exiting the context.
- The context manager must append
itemto the end oflstwhen entering the context. - The context manager must remove the last occurrence of
itemfromlstwhen exiting the context. - The context manager must restore the list to its previous state if an exception occurs inside the context.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 3. Розділ 3
single