We use Python 3.6

go back Level: Intermediate (img: IM / score: 3) level Bite 120. Write a numbers validation decorator

14 out of 15 users completed this Bite ...
Will you be Pythonista #15 to crack this Bite?
Average Bite difficulty 1-10 rating: 3.0
» You can do it! 😌

Let's get some more practice with decorators ... in this Bite you will write a decorator that checks if input arguments (*args *1) are positive integers. If one or more of the passed in args are not of type int, it throws a TypeError, if it is an int but < 0, it throws a ValueError.

That's it! Wrap it in a nice decorator and the tests will validate your code. Have fun!


*1) You would use *args when you're not sure how many arguments might be passed to your function, i.e. it allows you pass an arbitrary number of arguments to your function. - source

Github login button