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

Square bracket vs parenthesis in range.

It seems range does not require a square bracket. Is this true? What is the difference b/w range[0, 10, 1] and range(0, 10, 1)?

3 Answers

range is a built-in function so it will require parentheses.

Thanks, Kris. In the video, Ashley uses range[] then switches to range(). I tried both in my IDE and both ways worked. Can you help me understand why?

Can you provide a link to the video?

Well...I must have imagined the square brackets and them working in my IDE. I reviewed the video and re-tried the [] vs () and the square brackets do not work.

Thanks for the help :D

video: https://teamtreehouse.com/library/iterating-with-ranges