Python Forum
pattern question - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: pattern question (/thread-28575.html)



pattern question - spalisetty06 - Jul-24-2020

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



RE: pattern question - DeaD_EyE - Jul-24-2020

Use a white space for end.

        print(i, end = " ")



RE: pattern question - Gribouillis - Jul-24-2020

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)