Python provides a method called
.append() that you can use to add items to the end of a given list. This method is widely used either to add a single item to the end of a list or to populate a list using a
for loop. Learning how to use
.append() will help you process lists in your programs.
In this course, you learned:
- How to populate lists using
.append()along with a
- When to replace
.append()with a list comprehension
In addition, you explored some examples of how to use
.append() to create data structures, such as stacks and queues. This knowledge will allow you to use
.append() to grow your lists efficiently and effectively.
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.