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
  • 50,140
  • 28
  • 121
  • 140
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
  • 73,278
  • 37
  • 149
  • 186
Alexander R.
  • 1,756
  • 12
  • 19
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)
sumit-sampang-rai
  • 701
  • 1
  • 7
  • 16