0

I was practicing some coding and I decided to make a parrot translator. The basic point of this game is, that after every word in a sentence, you should put the syllable "pa". I had written the code for that:

    print("This is the PARROT Translator!")
    original = input("Please enter a sentence you want to translate: ")

    words = list(original.split())

    for words in words:
         print(words + "pa")

but the problem I have and I dont know how to fix is, when I split the sentence, the output wont be in the same line, but every word will be at it's own.

Murg
  • 129
  • 2
  • 11
  • 1
    Notice that you should write `for word in words:` not `for words in words:` – progmatico May 03 '18 at 17:49
  • 3
    Possible duplicate of [How to print without newline or space?](https://stackoverflow.com/questions/493386/how-to-print-without-newline-or-space) – nofinator May 03 '18 at 17:50

2 Answers2

3

You should use end="" at the end of your print:

print(words + "pa", end="")

EDIT:

For explanation you can read here

namokarm
  • 668
  • 1
  • 7
  • 20
NBlaine
  • 493
  • 2
  • 11
0

I am not very good in python, so possibly you will have some issues with version support, but this should work in most cases

import sys

print("This is the PARROT Translator!")
original = input("Please enter a sentence you want to translate: ")

words = list(original.split())

for word in words:
  sys.stdout.write(word + "pa")
AntonTkachov
  • 1,784
  • 1
  • 10
  • 29