0

I'm trying to pull data from two different lists in order to make a new directory. But Python says that the second list queue is not defined when I try to run it.

import csv
import time
import os, sys
from datetime import date

queuelist = ['ONE']
yearlist = ['2013']

year = str(date.today().year)
month = str(date.today().month)

for year in yearlist and queue in queuelist:
    os.mkdirs('{0}\{1}'.format(queue,year))
iOSecure
  • 232
  • 6
  • 18

1 Answers1

1

You probably want either a nested loop ...

for year in yearlist:
    for queue in queuelist:
        # ... to do stuff for every possible year/queue combination

or you want to zip the two lists ...

for year, queue in zip(yearlist, queuelist):
    # ... to do stuff with year-queue pairs of same index
user2390182
  • 72,016
  • 6
  • 67
  • 89