Reputation: 321
Please see my code below
for i in range (0,3):
url = "number/i"
print url
My expectation is
number/1
number/2
number/3
Can I also change URL to URL1= number/1 URL2=number/2 as well?
Upvotes: 0
Views: 56
Reputation: 2689
Pythons range defaults to starting at 0, and runs to one less that the stop value, in your case it will give 0, 1, 2
. You can either add one to get the values you want, or adjust your range to range(1, 4)
Then, to get the printed output you want, you'll need to convert the number to a string, like so
url = "number/" + str(i)
Upvotes: 2