title: Re-print Original List After Python Bubble Sort
body: <p>I am writing a Python 3 Bubble Sort program for a homework assignment and I cannot figure out how to get the original list to be reprinted (aka the unsorted list) after the list has already been sorted.</p>
  
  <p>The following already posted question gets the answer almost all the way but falls short of giving a solution for the second printed original list:</p>
  
  <p><a href="https://stackoverflow.com/questions/54382933/bubble-sort-in-python-3">Bubble Sort in Python 3</a></p>
  
  <p>Similar but does not address the print issue:
  <a href="https://stackoverflow.com/questions/895371/bubble-sort-homework">Bubble Sort Homework</a></p>
  
  <p>I am hoping in reposting that I can get a complete answer</p>
  
  <pre class="lang-py prettyprint-override"><code>import sys
  
  def bubblesort(mylist):
      changes = passes = 0
      last = len(mylist)
      swapped = True
      # This original list (below) correctly prints as unsorted:
      print("Original List: ", ','.join(map(str, mylist)) )
      while swapped:
          swapped = False
  
          for j in range(1, last):
              if mylist[j - 1] &gt; mylist[j]:
                  mylist[j], mylist[j - 1] = mylist[j - 1], mylist[j]  # Swap
                  changes += 1
                  swapped = True
                  last = j
  
          # Only prints and increases number of passes if there was a swap
          # Remove if statement for the correct number of passes
          if(swapped):
            passes += 1
            print('Pass', passes, ':' , ','.join(map(str, mylist)))
  
      # This original list (below) prints sorted:
      print("\nOriginal List: ", ','.join(map(str, mylist)) )
      print("Sorted List: ", ','.join(map(str, mylist)) )
      print("Number of passes =",passes)
      return mylist
  
  print("Welcome to a Bubble Sort Algorithm in Python!")
  
  mylist = " "
  while True:
      print("\nBubble sort in Python 3 Program")
      mylist = input("Enter a the value or type Exit to exit: ")
      if (mylist == "exit" or mylist == "Exit" or mylist == "EXIT"):
          print("Goodbye")
          sys.exit()
      else:
          mylist = [int(v) for v in mylist.split(',')]
          bubblesort(mylist)
  </code></pre>
  
  <p><strong>The program should produced the following printed results:</strong></p>
  
  <p>Original List: 4, 9, 74, 0, 9, 8, 28, 1</p>
  
  <p>Pass 1:  4, 9, 0, 9, 8, 28, 1, 74</p>
  
  <p>Pass 2:  4, 0, 9, 8, 9, 1, 28, 74</p>
  
  <p>Pass 3 : 0, 4, 8, 9, 1, 9, 28, 74</p>
  
  <p>Pass 4 : 0, 4, 8, 1, 9, 9, 28, 74</p>
  
  <p>Pass 5 : 0, 4, 1, 8, 9, 9, 28, 74</p>
  
  <p>Pass 6 : 0, 1, 4, 8, 9, 9, 28, 74</p>
  
  <p>Original List: 4, 9, 74, 0, 9, 8, 28, 1</p>
  
  <p>Sorted List: 0, 1, 4, 8, 9, 9, 28, 74</p>
  
  <p>Number of Passes: 6</p>
  
  <p><strong>Actual printed results:</strong></p>
  
  <p>Original List: 4, 9, 74, 0, 9, 8, 28, 1</p>
  
  <p>Pass 1:  4, 9, 0, 9, 8, 28, 1, 74</p>
  
  <p>Pass 2:  4, 0, 9, 8, 9, 1, 28, 74</p>
  
  <p>Pass 3 : 0, 4, 8, 9, 1, 9, 28, 74</p>
  
  <p>Pass 4 : 0, 4, 8, 1, 9, 9, 28, 74</p>
  
  <p>Pass 5 : 0, 4, 1, 8, 9, 9, 28, 74</p>
  
  <p>Pass 6 : 0, 1, 4, 8, 9, 9, 28, 74</p>
  
  <p>Original List: 0, 1, 4, 8, 9, 9, 28, 74</p>
  
  <p>Sorted List: 0, 1, 4, 8, 9, 9, 28, 74</p>
  
  <p><em>Original List appears sorted</em></p>