From the course: Programming Foundations: Beyond the Fundamentals
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Solution: Working with a collection - Python Tutorial
From the course: Programming Foundations: Beyond the Fundamentals
Solution: Working with a collection
(lively music) - Hope you had fun with that challenge. You might have had questions while doing it or you might have had a moment when you weren't sure about what to do next. If you did, that's totally normal. Understanding and working with programming concepts takes practice. Trying your hand at this challenge is a first step in building those muscles. Let me show you how I tackled this one. My start file has two sets of variables. Let's start with the first set, the four stars nearest to Earth. This is essentially an ordered list and a Python list is an ideal choice for grouping this data because the order matters. So I'll start by commenting out those existing variables and then I'll create a new variable called stars. After the equal sign, type an opening square bracket and then I press enter and I'm ready to enter values. These will just be strings separated by commas. I could copy and paste, but I'm a pretty fast…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Understanding collections2m 31s
-
(Locked)
Creating simple collections3m 16s
-
(Locked)
Creating more complex collections3m 22s
-
(Locked)
Working with collections3m 24s
-
(Locked)
Collections in other languages2m 3s
-
(Locked)
Challenge: Working with a collection1m 3s
-
(Locked)
Solution: Working with a collection5m 26s
-
-
-
-
-
-
-
-
-
-
-