Advertisement
here2share

# append_vs_extend.py

Jul 2nd, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. # append_vs_extend.py
  2.  
  3. x = [1, 2, 3]
  4. x.append([4, 5])
  5. print (x)
  6.  
  7. # gives you: [1, 2, 3, [4, 5]]
  8.  
  9.  
  10. x = [1, 2, 3]
  11. x.extend([4, 5])
  12. print (x)
  13.  
  14. # gives you: [1, 2, 3, 4, 5]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement