Teach Jenn Tech

Learning Python: Lists

Published on August 29 2024 by Jenn Junod

Written by Jenn Junod

In a recent stream, Jenn Junod and her co-host Damien tackled some challenging Python coding exercises, specifically focusing on list operations and indexing. The session was filled with trials and errors, as the pair navigated through complex problems, trying to find the most effective solutions. They discussed various methods for manipulating lists, including how to swap elements, determine list lengths, and identify specific conditions, such as whether someone was “fashionably late” to a party.

One of the key moments in the stream was when Jenn and Damien were tasked with determining the length of different lists and whether certain elements met specific criteria. The exercise required a deep understanding of list indexing, slicing, and the use of Python’s len() function. Despite some initial confusion and setbacks, the pair managed to work through the problems with the help of their audience, particularly with valuable insights from viewers like Sleepo and Blaze Labs.

The stream concluded with a particularly tough challenge that involved identifying the “fashionably late” attendees to a party. This problem required Jenn to think critically about list indexing and conditionals, ultimately leading to a discussion about the importance of breaking down complex problems into manageable steps. Although the session ended before fully resolving the final challenge, the stream highlighted the value of persistence and community support in learning to code.

Questions from the stream:

1. What does the len() function do in Python?

  • The len() function returns the number of items in a list or any other iterable, effectively giving the length of the list.

2. How do you swap elements in a Python list without using a temporary variable?

  • You can swap elements in a Python list using tuple unpacking, e.g., a, b = b, a, where a and b are the elements you want to swap.

3. What does it mean for an attendee to be “fashionably late” according to the problem?

  • An attendee is considered “fashionably late” if they arrive after at least half of the other guests but are not the very last to arrive.

Enjoy learning with us?

We’re using Kaggle Learn - Python.

Follow us!

JennDamien
- Twitch- Instagram
- YouTube- LinkedIn
- Twitter
- LinkedIn
← Back to content