PYTHON   23

swappython

Guest on 22nd September 2022 12:28:13 AM

  1. # define the swap function
  2.  
  3. def swap(lst, i, j):
  4.         temp = lst[i]
  5.         lst[i] = lst[j]
  6.         lst[j] = temp
  7.         return lst
  8.  
  9. x = [1, 2, 3]
  10. y = swap(x, 1, 2)
  11. print y

Raw Paste


Login or Register to edit or fork this paste. It's free.