编写一个获取整数的程序,它的位数没有指定。如果 n 是数字本身,则将每个数字打印 n 次

Write a program that gets an integer , which its number of digits is not specified. then print each digit n times if n is the digit itself

我该如何解决这个问题? 像这样: 6041 6:666666 0: 4: 4444 1:1 我只知道为了分隔数字我们应该这样做,我认为:

num = int(input)
while num > 0:
res = num // 10
num = num % 10

一种方法是将数字保留为字符串,然后在循环中将第一个数字转换为 int,打印 n 次,然后将其删除。重复循环直到字符串为空:

num = input("Input a number: ")
while len(num) > 0:
    digit = num[0]
    for i in range(int(digit)):
        print(digit, end="")
    num = num[1:]