I am trying to figure out how to use the code below with list comprehension.
link = 'page={}&index={}'
index = 10
links = []
for page in range(2, 4):
links.append(link.format(page, index))
index += 10
I have tried many different ways and Googled as much as possible (maybe I am not searching for the correct terms?). I am still unable to figure it out. Below is one of the ways I tried but I get a SyntaxError
error.
link = 'page={}&index={}'
index = 10
links = [link.format(link, index) for page in range(2, 4) index += 10]
This should be the output of the list comprehension:
['page=2&index=10', 'page=3&index=20']
If anyone has any ideas it would be greatly appreciated it. Thank you!