Printing a Yearly Calendar
Question: I am trying to print a yearly calendar with python and I have hit a wall. I am
getting the days of the month printed, but I am not sure how to make the
output jump to a new line after 7 days.

I am using a for loop to print the days of the month.

I need the numbers to go to a new line in order for the days of the week and
numbers to line up. Any advice would help.


Answer: Is there a reason you aren't using the built-in
[calendar](http://docs.python.org/2/library/calendar.html) module?

    
    
    >>> import calendar
    >>> cal = calendar.TextCalendar()
    >>> cal.prmonth(2013, 5)
    
          May 2013
    Mo Tu We Th Fr Sa Su
           1  2  3  4  5
     6  7  8  9 10 11 12
    13 14 15 16 17 18 19
    20 21 22 23 24 25 26
    27 28 29 30 31
    
    >>> cal.pryear(2013)
                                      2013
    
          January                   February                   March
    Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
        1  2  3  4  5  6                   1  2  3                   1  2  3
     7  8  9 10 11 12 13       4  5  6  7  8  9 10       4  5  6  7  8  9 10
    14 15 16 17 18 19 20      11 12 13 14 15 16 17      11 12 13 14 15 16 17
    21 22 23 24 25 26 27      18 19 20 21 22 23 24      18 19 20 21 22 23 24
    28 29 30 31               25 26 27 28               25 26 27 28 29 30 31
    
           April                      May                       June
    Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
     1  2  3  4  5  6  7             1  2  3  4  5                      1  2
     8  9 10 11 12 13 14       6  7  8  9 10 11 12       3  4  5  6  7  8  9
    15 16 17 18 19 20 21      13 14 15 16 17 18 19      10 11 12 13 14 15 16
    22 23 24 25 26 27 28      20 21 22 23 24 25 26      17 18 19 20 21 22 23
    29 30                     27 28 29 30 31            24 25 26 27 28 29 30
    
            July                     August                  September
    Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
     1  2  3  4  5  6  7                1  2  3  4                         1
     8  9 10 11 12 13 14       5  6  7  8  9 10 11       2  3  4  5  6  7  8
    15 16 17 18 19 20 21      12 13 14 15 16 17 18       9 10 11 12 13 14 15
    22 23 24 25 26 27 28      19 20 21 22 23 24 25      16 17 18 19 20 21 22
    29 30 31                  26 27 28 29 30 31         23 24 25 26 27 28 29
                                                        30
    
          October                   November                  December
    Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
        1  2  3  4  5  6                   1  2  3                         1
     7  8  9 10 11 12 13       4  5  6  7  8  9 10       2  3  4  5  6  7  8
    14 15 16 17 18 19 20      11 12 13 14 15 16 17       9 10 11 12 13 14 15
    21 22 23 24 25 26 27      18 19 20 21 22 23 24      16 17 18 19 20 21 22
    28 29 30 31               25 26 27 28 29 30         23 24 25 26 27 28 29
                                                        30 31
    

