Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Temporary List Modification | Practice with Context Managers
Practice
Projects
Quizzes & Challenges
Quizer
Challenges
/
Python Context Managers
Seksjon 3. Kapittel 3
single

single

bookChallenge: Temporary List Modification

Sveip for å vise menyen

Oppgave

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 item to the end of lst when entering the context.
  • The context manager must remove the last occurrence of item from lst when exiting the context.
  • The context manager must restore the list to its previous state if an exception occurs inside the context.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 3
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt