3 Going on a picnic: Working with lists
Writing code makes me hungry! Let’s write a program to list some tasty foods we’d like to eat.
So far we’ve worked with single variables, like a name to say “hello” to or a nautical-themed object to point out. In this program, we want to keep track of one or more foods that we will store in a list
, a variable that can hold any number of items. We use lists all the time in real life. Maybe it’s your top-five favorite songs, your birthday wish list, or a bucket list of the best types of buckets.
In this chapter, we’re going on a picnic, and we want to print a list of items to bring along. You will learn to
-
Write a program that accepts multiple positional arguments
-
Use
if
,elif
, andelse
to handle conditional ...
Get Tiny Python Projects now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.