How to end a while loop properly?
<p>I want to create a program that asks a user for sentences that then combine to create a story that is displayed to the user. The user decides how many sentences he or she wishes to write. </p>

<p>This is probably a dumb question with a simple answer, but with the code below a <code>q</code> or <code>Q</code> is always added to the end of the story when I don't want the end command to be included. How can I eliminate this <code>q</code> from the printed story so that the user only gets his or her story returned to them. </p>

<p>Thank you for any help.  </p>

<pre><code>sent = ""
story = ""
while sent != 'q' and sent != 'Q':

    sent = input("Enter the sentence(Enter 'q' to quit): ")
    story += sent


print(story)
</code></pre>

<p>You should check after input, if the look should end or not. If so you can exit using <code>break</code></p>

<pre><code>story = ""
while True
    sentence = input("Enter the sentence(Enter 'q' to quit): ")
    if sentence.lower() != 'q':
        story += sent
    else:
        break

print(story)
</code></pre>

python