Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Argument Validation Decorator | Decorator Practice Lab
Python Decorators Explained

bookChallenge: Argument Validation Decorator

Oppgave

Swipe to start coding

Create a decorator named positive_integer_args that checks all arguments passed to a function. The decorator must ensure every argument (both positional and keyword) is a positive integer. If any argument is not a positive integer, the decorator should raise a ValueError. Only if all arguments are valid should the original function execute.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 1
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

close

bookChallenge: Argument Validation Decorator

Sveip for å vise menyen

Oppgave

Swipe to start coding

Create a decorator named positive_integer_args that checks all arguments passed to a function. The decorator must ensure every argument (both positional and keyword) is a positive integer. If any argument is not a positive integer, the decorator should raise a ValueError. Only if all arguments are valid should the original function execute.

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 4. Kapittel 1
single

single

some-alt