Challenge: Temporary List Modification
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 3
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Awesome!
Completion rate improved to 8.33
Challenge: Temporary List Modification
Deslize para mostrar o menu
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 3
single