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

Python

Why index+1?

for index, letters in enumerate('abcdefghijklmnopqurstuvwxyz'):
    print("{} : {}".format(index,letters))

Why did instructor use index+1? I get same output without it. It always makes me annoying when someone uses count or index in code. I don't think instructor did great job in explaining those keywords at all.

2 Answers

Steven Parker
Steven Parker
243,656 Points

You should not get the same output without adding 1. Index numbers begin at 0, so adding 1 allows the display to show the first item as number 1 instead of 0.

Okay and why the index has to start with 1?

Steven Parker
Steven Parker
243,656 Points

It depends on who you are creating the list for. Most people are more comfortable with counting from 1. Programmers would probably be just as happy to accept it starting with 0.