def print_number(num):
num=str(num)
for i in range(len(num)):
if num[i]=='0':
print("### ",end="")
elif num[i]=='1':
print(" # ",end="")
elif num[i]=='2':
print("### ",end="")
elif num[i]=='3':
print("### ",end="")
elif num[i]=='4':
print("# # ",end="")
elif num[i]=='5':
print("### ",end="")
elif num[i]=='6':
print("### ",end="")
elif num[i]=='7':
print("### ",end="")
elif num[i]=='8':
print("### ",end="")
elif num[i]=='9':
print("### ",end="")
print("")
for i in range(len(num)):
if num[i]=='0':
print("# # ",end="")
elif num[i]=='1':
print(" # ",end="")
elif num[i]=='2':
print(" # ",end="")
elif num[i]=='3':
print(" # ",end="")
elif num[i]=='4':
print("# # ",end="")
elif num[i]=='5':
print("# ",end="")
elif num[i]=='6':
print("# ",end="")
elif num[i]=='7':
print(" # ",end="")
elif num[i]=='8':
print("# # ",end="")
elif num[i]=='9':
print("# # ",end="")
print("")
for i in range(len(num)):
if num[i]=='0':
print("# # ",end="")
elif num[i]=='1':
print(" # ",end="")
elif num[i]=='2':
print("### ",end="")
elif num[i]=='3':
print("### ",end="")
elif num[i]=='4':
print("### ",end="")
elif num[i]=='5':
print("### ",end="")
elif num[i]=='6':
print("### ",end="")
elif num[i]=='7':
print(" # ",end="")
elif num[i]=='8':
print("### ",end="")
elif num[i]=='9':
print("### ",end="")
print("")
for i in range(len(num)):
if num[i]=='0':
print("# # ",end="")
elif num[i]=='1':
print(" # ",end="")
elif num[i]=='2':
print("# ",end="")
elif num[i]=='3':
print(" # ",end="")
elif num[i]=='4':
print(" # ",end="")
elif num[i]=='5':
print(" # ",end="")
elif num[i]=='6':
print("# # ",end="")
elif num[i]=='7':
print(" # ",end="")
elif num[i]=='8':
print("# # ",end="")
elif num[i]=='9':
print(" # ",end="")
print("")
for i in range(len(num)):
if num[i]=='0':
print("### ",end="")
elif num[i]=='1':
print(" # ",end="")
elif num[i]=='2':
print("### ",end="")
elif num[i]=='3':
print("### ",end="")
elif num[i]=='4':
print(" # ",end="")
elif num[i]=='5':
print("### ",end="")
elif num[i]=='6':
print("### ",end="")
elif num[i]=='7':
print(" # ",end="")
elif num[i]=='8':
print("### ",end="")
elif num[i]=='9':
print("### ",end="")
print("")
print_number(int(input("Enter the number you wish to display: ")))
你们可以试一下output
Enter the number you wish to display: 9081726354
结果是运行正常的,格式也是对的,但怎样能把这段代码给简化