Printing issue in Python
Question: I feel like an idiot for even asking this but does anyone have any idea why my
code is printing the list after every shuffle?

    
    
    def shuffle(L, nswaps):
        n = 0
        for item in L:
            while n < nswaps:
                card_one = choose(L)
                card_two = choose(L)
                if card_two == card_one:
                    card_two = choose(L)
                n += 1
                L[card_one], L[card_two] = L[card_two], L[card_one]
            print L
    

NB I haven't pasted the import/ calling the function stuff as it's not
relevant to the question.


Answer: Your print statement is inside the for loop, so it's going to print L for each
element in L.

Try un-indenting it to the same level as the for loop, to put it outside the
loop

