number of weeks in a given month python
<p>I'm trying to get the number of weeks in any month. for example:</p>

<p><code>for this month August 2016, the days of the month streches over 5 weeks. while for October 2016 the number of weeks are 6</code>. </p>

<p>Is there any elegant way to find out this number? tried using calendar and datetime but I couldn't find anything that can help me solve my problem.</p>

<blockquote>
  <p>P.S I'm using python 2.6</p>
</blockquote>

<p>Thanks in advance!</p>

<p>Here's a quicky:</p>

<pre><code>&gt;&gt;&gt; import calendar
&gt;&gt;&gt; print calendar.month(2016,10)
    October 2016
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
</code></pre>

<p>Count the lines :)</p>

<pre><code>len(calendar.month(2016,10).split('\n')) - 3
</code></pre>

python calendar