Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # insert_pitfall.py
- # pitfall
- a = [1,2,3,4]
- a.insert(-1,5)
- print (a)
- # [1, 2, 3, 5, 4]
- # solution
- a = [1,2,3,4]
- a.insert(len(a),5)
- print (a)
- # [1, 2, 3, 4, 5]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement