2

I have issues with python that i cant figure it out. I want to print a repetition of a word when the user enter a word and then he will tell how many times that word will repeat. I cant * by the way . Here code so far

b = raw_input 'enter word'
c = input 'enter the amount of time the word will repeat'

for g in range (c)
    print (b)

like you see you can see the repetition of the input but on vertical line, how I can print it horizontal?

Bhargav Rao
  • 45,811
  • 27
  • 120
  • 136
Luis Colon
  • 27
  • 4
  • possible duplicate of [How to print in Python without newline or space?](http://stackoverflow.com/questions/493386/how-to-print-in-python-without-newline-or-space) – livibetter Mar 27 '15 at 07:26

2 Answers2

5

Very simple. Just add comma.

print (b),

So your code becomes:

b = raw_input('enter word: ')
c = input('enter the amount of time the word will repeat: ')

for g in range (c):
    print b,
Anshul Goyal
  • 67,326
  • 35
  • 140
  • 172
Alexander R.
  • 1,668
  • 12
  • 18
1

Here's how you do it

import sys
b = raw_input('enter word')
c = input('enter the amount of time the word will repeat')

for g in range (c):
    sys.stdout.write(b)
mailtosumitrai
  • 691
  • 1
  • 7
  • 16