title: How to swap 2 items in a list in Python?
body: <p>Wondering how to swap two items in a list (or an array) in Python?</p>
  <p>Some example code showing the expected output:</p>
  <pre><code>def swap_name(name_list): 
  &quot;&quot;&quot; (list of str) -&gt; NoneType 
  
  Modify name_list so that the first name and last name are swapped. 
              
  &gt;&gt;&gt; name = ['Tommy', 'Jason'] 
  &gt;&gt;&gt; swap_name(name) 
  &gt;&gt;&gt; name 
  ['Jason', 'Tommy'] 
  
  &quot;&quot;&quot; 
  # My Answer which is not complete and i don't know how to complete it or how to correct it. I tried in every way but it didn't work...I need your help
  
  for i in range (len (name_list)):
      name_list[i] = [name_list[1] , name_list[0]]
      
  </code></pre>