Python Forum

Full Version: pattern question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I add a space in between numbers?
n = int(input("Please enter the number of times "))
for i in range(1, n+1):
    for j in range(n):
        print(i, end = "")
    print()
Output:
Please enter the number of times 3 111 222 333
Use a white space for end.

        print(i, end = " ")
Use this for example
n = int(input("Please enter the number of times "))
for i in range(1, n+1):
    for j in range(n-1):
        print(i, end = " ")
    print(i)