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 trialBen Bassler
1,806 PointsWhat if I want to have a step but not a stop?
In the Range Function the first 'argument' is start, then stop and then step. But what if I want to have a step but not a stop? Would it look something like this ( range(1, ,2) ) ?
2 Answers
Josh Keenan
20,315 PointsYou can't have this sadly, in python there are two possible options, range with just a stop, or range with a start and stop, and optional step. Sadly it doesn't offer much else.
James Ball
2,074 PointsNot having a stop would be an infinite loop and therefore you could use the while True statement. Within the while True statement you could have a counter variable which has a set step. You'd want a way to break out of the infinite loop at some point though.
Ben Bassler
1,806 PointsBen Bassler
1,806 PointsAlright thanks!