Pedagogical reasoning behind a minor difference in two loops I keep seeing examples like the first program bellow, in teaching materials.
Is there a pedagogical reason to teach this first program, compared to the second?
answer=input(&quot;Do you wish to continue?&quot;)

while answer == &quot;yes&quot;:
    answer=input(&quot;Do you wish to continue?&quot;)

print (&quot;Good bye&quot;)

2nd program
answer=&quot;yes&quot;

while answer == &quot;yes&quot;:
    answer=input(&quot;Do you wish to continue?&quot;)

print (&quot;Good bye&quot;)


An argument for the 2nd one
I think the 2nd program is more elegant: it has less repeated code.
note: when I wrote this I copied the 1st line into the other 2 places, then when I tested it I discovered that I missed the closing &quot;, so had to fix it 3 times. This is an example of why repeated code is a problem, when a program needs re-editing. In the second version, the only repeated code is &quot;yes&quot;, so still some room for improvement.
This is a really good place to introduce boolean variables (or just to use them, if they've already been introduced. It also introduces the idea of descriptive variable names.  

user_wishes_to_continue = True

while user_wishes_to_continue:
    answer = raw_input("Do you wish to continue?")
    if answer != "yes":
        user_wishes_to_continue = False

print ("Good bye")


Note: here I use raw_input, which returns the user input as a string, rather than input, which interprets the  user input as python code (meaning that you have to put "yes" with the quotation marks each time.