I have the following Code:
import urllib.request, json
for i in range(10):
with urllib.request.urlopen(baselink[i]) as url:
data[i] = json.loads(url.read().decode())
My baselink[i] are different URL strings. I am having difficulties to get my loop to run. Normally I am used to loops of the following type:
for i in range(10):
data[i] = something[i]
But I can't figure out how to get the loop to properly use the following "with ... as"-part:
with urllib.request.urlopen(baselink[i]) as url:
The error message is : "IndentationError: expected an indented block" . I tried to put the part after ":" in brackets but that didn't solve the problem. What I need as result is the outcomes of data[1], data[2], data[3], etc. ...