For loop with multiple variables in python 2.7.
I am not certain how to go about this, I have a function that goes to a site and downloads a .csv file. It saves the .csv file in a particular format: name_uniqueID_dataType.csv. here is the code
import requests name = "name1" id = "id1" dataType = "type1" def downloadData(): URL = "http://www.website.com/data/%s" %name #downloads the file from the website. The last part of the URL is the name r = requests.get(URL) with open("data/%s_%s_%s.csv" %(name, id, dataType), "wb") as code: #create the file in the format name_id_dataType code.write(r.content) downloadData()
The code downloads the file and saves it perfectly fine. I want to run a for loop on the function that takes those three variables each time. The variables will be written as lists.
name = ["name1", "name2"] id = ["id1", "id2"] dataType = ["type1", "type2"]
There will be over 100 different items listed in each list with the same amount of items in each variable. Is there any way to accomplish this using a for loop in python 2.7. I have been doing research on this for the better part of a day but I can't find a way to do it. Please note that I am new to python and this is my first question. Any assistance or guidance would be greatly appreciated.