I need to carry out a GET request for each value that is returned in a variable. My variable is called epics and looks like this:
IN.D.VIX.MONTH2.IP,TM.D.ATHENS.DAILY.IP,KB.D.HEALTH.DAILY.IP,CS.D.EURSEK.TODAY.IP,CF.D.USDNOK.JUN.IP,CF.D.GBPJPY.MAR.IP,IR.D.IB.Month3.IP,IX.D.SUNFUN.DAILY.IP
I basically want to append one epic at a time and perform a get request e.g.
Request 1
http://api.example.com/v1.14/member?id=IN.D.VIX.MONTH2.IP
Request 2
http://api.example.com/v1.14/member?id=TM.D.ATHENS.DAILY.IP
When I run the code below I get TypeError: range() integer end argument expected, got str.
url = "http://api.example.com/v1.14/epics?id=" + str(epics)
for i in range(epics):
print(url)
for i in range(len(epics))You need to call thelen()function to get the length of the list when using range, this will iterate as many times thatlen()returns.