How can I print the entire converted sentence on a single line?
<p>I am trying to expand on Codeacademy's Pig Latin converter to practice basic programming concepts. </p>

<p>I believe I have the logic nearly right (I'm sure it's not as concise as it could be!) and now I am trying to output the converted Pig Latin sentence entered by the user on a single line.</p>

<p>If I print from inside the for loop it prints on new lines each time. If I print from outside it only prints the first word as it is not iterating through all the words. </p>

<p>Could you please advise where I am going wrong?</p>

<p>Many, many thanks for your help.</p>

<pre><code>pyg = 'ay'

print ("Welcome to Matt's Pig Latin Converter!")

def convert(original):
    while True:
        if len(original) &gt; 0 and (original.isalpha() or " " in original):
            print "You entered \"%s\"." % original
            split_list = original.split()

            for word in split_list:
                first = word[0]
                new_sentence = word[1:] + first + pyg
                final_sentence = "".join(new_sentence)
                print final_sentence


            break

        else:
            print ("That's not a valid input. Please try again.")
            return convert(raw_input("Please enter a word: "))

convert(raw_input("Please enter a word: "))
</code></pre>

<p>Your issue is here:</p>

<pre><code>for word in split_list:
  first = word[0]
  new_sentence = word[1:] + first + pyg
  final_sentence = "".join(new_sentence)
  print final_sentence
</code></pre>

<p>You are joining a single word to itself.  You will want to save all the words from inside the loop, then print them once the loop are processed them all.</p>

<pre><code>final = []
for word in split_list:
  new_word = word[1:] + word[0] + pyg
  final.append(new_word)

print ' '.join(final)
</code></pre>

<p>Or, just for fun, here's the one-liner:</p>

<pre><code>print ' '.join([word[1:]+word[0]+'ay' for word in split_list])
</code></pre>

<p><strong><em>EDIT:</em></strong>  Also, @furas makes a good point in their comment, to print with <strong>no newline</strong> simply add a <code>,</code> to the end of the print statement:</p>

<pre><code>for word in split_list:
  first = word[0]
  print word[1:] + first + pyg,
</code></pre>

python join printing