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

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…

Contents