Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Collections and Control Flow Control Flow With Loops While and Repeat While

Subscripts?

What is a subscript? We haven't learned about those and he uses it in "print(todo[index])" Please help!

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Subscript is the term used to describe the value in square brackets when using that to access a collection like Array or Dictionary. For example, in the array myArray = [1, 2, 3, 4] we would access the 0-th element (1) by writing myArray[0]. The [0] is the subscript.

Similarly, in a dictionary, such as myDictionary = ["a" : "apple", "b" : "banana"] we could access "banana" using myDictionary["b"] where the key (here "b") in square brackets is the subscript.

Hope that helps.

So for example, if number = 3 and I do print(randomArray[number]) I would get the fourth value in the array?

thanks!