title: Renaming list indices in Python - seeking explanation of code
body: <p>I am in the process of learning Python, which is my first real experience with programming. I have been working through a series of lessons found <a href="http://python-textbok.readthedocs.io/en/1.0/Loop_Control_Statements.html#exercise-3" rel="nofollow noreferrer">here</a>.</p>
  
  <p>The lesson I am on is concerned with nesting loops. However, in one exercise they offer a solution to the problem by essentially renaming the indices of the list items. Keep in mind, this is not a dictionary being used. While these lessons have been going great, this one answer to the problem baffles me as there is no explanation of what is going on. Furthermore, I cannot seem to find reference to this technique anywhere else in the lessons series, or elsewhere.</p>
  
  <p>Here is what the exercise is asking me to do.
  1 "Write a program which uses a nested for loop to populate a three-dimensional list representing a calendar: the top-level list should contain a sub-list for each month, and each month should contain four weeks. Each week should be an empty list.
  2 Modify your code to make it easier to access a month in the calendar by a human-readable month name, and each week by a name which is numbered starting from 1. Add an event (in the form of a string description) to the second week in July.</p>
  
  <p>The first part was no problem. The second part was a bit challenging given the parameters, but the answer given was not what I expected.</p>
  
  <p>I've seen explanations on stack overflow of using dictionaries to accomplish this sort of naming indices goal:
  <a href="https://stackoverflow.com/questions/178199/python-can-i-have-a-list-with-named-indices">Python: can I have a list with named indices?</a></p>
  
  <p>However, here was the solution offered:</p>
  
  <pre><code>(JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER) = range(12)
  
  (WEEK_1, WEEK_2, WEEK_3, WEEK_4) = range(4)
  
  calendar = []
  for m in range(12):
      month = []
  
      for w in range(4):
          month.append([])
  
      calendar.append(month)
  calendar[JULY][WEEK_2].append("Go on holiday!")
  print(calendar)
  </code></pre>
  
  <p>Can someone explain how this works exactly? I find it odd that the month and week names do not have to be strings, but rather just variable names. I think each variable name is being assigned to each item in the particular range defined. However, I'm surprised that variable names can be used as the list indices. Once this is done, I cannot refer to an index by numerical value anymore. For example, I cannot use:</p>
  
  <pre><code>calendar[1][1].append("This is the first week of January.")
  </code></pre>
  
  <p>I am further confused by this because when I write a simple loop after the last line:</p>
  
  <pre><code>for i in range(12):
      print(i)
  </code></pre>
  
  <p>I get a print out of numbers 0 through 11 as usual, but not these variable names.</p>
  
  <p>What's going on exactly, and how does this work?</p>