Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- our_list = [1,1,1, 2, "Joy", 3.2, 7, 8, "Peter", 1]
- print(our_list[0:3])
- #returns the first to third item
- print(our_list[:3])
- #alternaively, we write this to return the first to third item
- print(our_list[2:7])
- #returns the 3rd to 7th items
- print(our_list[2:])
- #returns from the third item to the last item
- print(our_list[-4:])
- #returns the last four items i.e counting backwards
- print(our_list[-6:-2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement