Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Lists and Tuples in Python: Conclusion

In this course, you learned about working with lists and tuples. Lists and tuples are arguably Python’s most versatile, useful data types. You’ll find them in virtually every non-trivial Python program.

Here’s what you learned in this tutorial: You covered the important characteristics of lists and tuples. You learned how to define them and how to manipulate them. You now have a good feel for when and how to use these object types in a Python program.

Download

Course Slides (PDF)

1.2 MB

Take the Quiz: Test your knowledge with our interactive “Python Lists and Tuples” quiz. You’ll receive a score upon completion to help you track your learning progress:


Interactive Quiz

Python Lists and Tuples

Test your understanding of Python lists and tuples.

slickrick on Sept. 4, 2019

Fantastic! This really helped me level up my understanding of lists and tuples. Keep up the great work!

Pygator on Sept. 29, 2019

Really like your presentation style, favorite presenter for sure. Thanks again!

Cyntia Goulart on Oct. 27, 2019

OMG! I thought I knew Python well and you proved me wrong. Know what it is is totally different of knowing how to use it. I am so glad I took this course. Thank you! Thank you! Greetings from Brazil! :D

Levi on March 13, 2020

Thought I had a good handle on tuples and lists, but I learned probably twice as much as I knew before. Super in-depth, great course.

Sandro on March 16, 2020

Mmmm… baaacon. Mmm.

Thanks for the interesting piece about tuples being faster than lists. So in for-loops, if we iterate through a list that we know should not be changing, then tuples are the way to go.

wayne2056 on March 26, 2020

I’m trying to teach this old dog new tricks… spent some time searching for how the heck do I make an array in python ( old habits )… duh it’s a list. Very cool

pshapard on March 29, 2020

So much here to take in. Lots to know and remember. Need to look over the slicing and indexing functions. Thanks for the course and great instructor

Cristian Palau on April 15, 2020

Thank you for this great course!

birajksahu on June 21, 2020

Loved it! I can easily say I have scaled myself up on this topic. Just one suggestion- can we include some more practice programs- Q&A

Ben Nduwuba on June 24, 2020

Fantastic !! Well done Chris

Alain Rouleau on Aug. 2, 2020

Thanks, really enjoyed the course. All very interesting.

My favourite list method by far is the pop() method. It’s extremely powerful yet so easy to use. I put together some sample code to illustrate how you can pop() not just strings, integers, etc. But your own objects as well.

For people not familiar with Object-Oriented Programming (OOP) don’t worry. Instead of a string object being popped it’s an airplane object. Each airport has a variable called ‘tarmac’ which is just a list to hold the airplane. So, to fly the airplane from London to New York I just pop() it from one list to another list. How crazy is that!

>>> class Airplane: pass
>>> class Airport:
...    def __init__(self):
...        self.tarmac = []  # List to hold the airplane

>>> boeing_747 = Airplane()
>>> london_heathrow = Airport()
>>> new_york_jfk = Airport()

>>> boeing_747
<__main__.Airplane at 0x1f4e3439d90>
>>> london_heathrow
<__main__.Airport at 0x1f4e3439d00>
>>> new_york_jfk
<__main__.Airport at 0x1f4e3447f40>

>>> print(london_heathrow.tarmac, new_york_jfk.tarmac)
[] []  # Two empty tarmacs
>>> london_heathrow.tarmac.append(boeing_747)  # Move plane to London tarmac
>>> print(london_heathrow.tarmac, new_york_jfk.tarmac)
[<__main__.Airplane object at 0x000001F4E3439D90>] []  # Plane in London

>>> new_york_jfk.tarmac.append(london_heathrow.tarmac.pop())  # Fly to NY

>>> print(london_heathrow.tarmac, new_york_jfk.tarmac)
[] [<__main__.Airplane object at 0x000001F4E3439D90>]  # Plane now in NY

Now think of what you could do with a deck of cards, popping each card off the top of the deck. Or moving cars from one parking lot to another. It’s crazy. You can have so much fun with the pop() method, LOL

cherianzachariah on Aug. 5, 2020

There is a lot of new little things that I learnt from this course. Thank you and keep up the good work. I am loving it so far.

Ghani on Oct. 20, 2020

Very good course; thank you so much!

Rupesh Kolatwar on Jan. 24, 2022

Thank You So much!!! feeling a bit confident now about the list. can you please share any project for practice ?

rwelk on Feb. 3, 2024

Very Interesting course it’s got me looking over scripts I have written in the past to see what kind of improvements I can make to them. Great presentation! Thank you

Become a Member to join the conversation.