Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pattern question
#1
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
Reply
#2
Use a white space for end.

        print(i, end = " ")
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pattern question spalisetty06 1 1,333 Jul-24-2020, 12:27 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020