Is there any way to display a list in Python with leading zeroes on numbers <= 9, but without using strings?
I'm helping a student on an assignment, and his module calculates a list of random numbers and returns that list to his main program. So it's not possible to use format() in this situation.
import random
list = []
x = 0
while x < 6:
number = random.randint(1,70)
if number <= 9:
temp = str(number)
temp = temp.zfill(2)
list.append(temp)
else:
list.append(str(number))
x+=1
print(list)
Example output:
['16', '41', '17', '40', '01', '28']
Desired output:
[16, 41, 17, 40, 01, 28]