0

I tried to get the output of python as

def main():
    i=raw_input()
    a=input()
    print(i*a)
    main()

input:hello, 2. output: "hellohello" but i am getting output as output:" hello hello " .how can i get the two strings as output continuously in same line from one print statement.for example:"hellohello "

Moinuddin Quadri
  • 46,825
  • 13
  • 96
  • 126

2 Answers2

0

based on the fact that you are using raw_input I'm assuming you are using python 2. Therefor you could just change the print() with a print and your code should work

def main():
  i=raw_input()
  a=input()
  print i*a  <---
  main()
bravosierra99
  • 1,331
  • 11
  • 23
0

To remove the white space from the single execution of print. Use .strip() function as (as I believe you have white space within your i string):

print(i.strip()*a)

But if you want all the executions of print in single line, you should use end argument of print to define empty string. Your print statement should be like:

print(i.strip()*a, end='')
Moinuddin Quadri
  • 46,825
  • 13
  • 96
  • 126