-4
name = input("What's your name?? ")
print(10 * name  ) 

prints the name 10 times in a row but if I want the name to be printed in columns 10 times how should I do thanks

Divyessh
  • 1,774
  • 1
  • 3
  • 21
Sairam Sargu
  • 1
  • 1
  • 1
  • Does this answer your question? [How do I specify new lines on Python, when writing on files?](https://stackoverflow.com/questions/11497376/how-do-i-specify-new-lines-on-python-when-writing-on-files) – funie200 Jul 30 '20 at 08:10

5 Answers5

2

You can simply append a newline character at the end of the name:

name = input("What's your name??")
print(10 * (name + '\n')) 

\n is the newline character - anything printed after it will go to the next line.

Susmit Agrawal
  • 3,394
  • 2
  • 12
  • 26
1
name = input("What's your name?? ")
print(10 * (name+"\n")  )
Ezrealhao
  • 11
  • 1
0

You can print 10 times your name, using '\n' (the new line character) as a separator:

name = input("What's your name??")
print(*(name for i in range(10)), sep='\n')

You could also use itertools.repeat:

from itertools import repeat

name = input("What's your name??")
print(*repeat(name, 10), sep='\n')
Riccardo Bucco
  • 11,231
  • 3
  • 17
  • 42
-2
name = input("What's your name?? ")
print(10 * (name+'\n')) 

you can use from the above code it is the beautiful character of python, but I suggest you to use of:

name = input("What's your name?? ")
for i in range(10):
    print(name)

that will be the real coder's work

Fayyoz24
  • 1
  • 3
-3

By using for loop:

for i in range(1,11,+1):
    i=name              
    print(i)
gab
  • 645
  • 7
  • 30
vishal
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 16 '22 at 18:22