Reputation: 6694
I'm very new to this: but I have this string:
urls = ['http://example.com/page_%s.html' % page for page in xrange(0,50)]
which runs from 0,1,2,3 ... 50.
The question is how can i make run by skipping 5 number in each iteration?
The number should run like this: 0, 5, 10, 15 ... 50.
Upvotes: 0
Views: 253
Reputation: 22041
You can try this:
urls = map('http://example.com/page_{}.html'.format, range(0, 50, 5))
range
and xrange
take an optional step
argument as the third parameter.
Upvotes: 3
Reputation: 2360
Just adding the 5 as another argument to xrange should do that
urls = ['http://example.com/page_%s.html' % page for page in xrange(0,50,5)]
Upvotes: 3