I have a positive integer variable which can have values between 0 to 999. This integer is then passed to a software.
To pass into this software the integer should a
You can do this by using ljust and str, then casting the result as an int.
ljust
str
int
>>> numbers = [1, 19, 255] >>> [int(str(num).ljust(3, '0')) for num in numbers] [100, 190, 255]
More on ljust here: https://docs.python.org/2/library/stdtypes.html#string-methods