Why is my condition in python not being met
<p>I have a list of filenames sorted by creation date. These files contain a datetime in the filename for their creation date time. I am attempting to create a sub list for all files after a certain time. </p>

<p>Full list of files -</p>

<pre><code>Allfilenames = ['CCN-200 data 130321055347.csv',
'CCN-200 data 130321060000.csv',
'CCN-200 data 130321063235.csv',
'CCN-200 data 130321070000.csv',
'CCN-200 data 130321080000.csv',
'CCN-200 data 130321090000.csv',
'CCN-200 data 130321100000.csv',
'CCN-200 data 130321110000.csv',
'CCN-200 data 130321120000.csv',
'CCN-200 data 130321130000.csv',
'CCN-200 data 130321140000.csv',
'CCN-200 data 130321150000.csv']
</code></pre>

<p><code>positions [19:24]</code> give the time in format hhmmss. I am using</p>

<pre><code>filenames = [s for s in Allfilenames if os.path.basename(s)[19:24] &gt;= TOffRound]

TOffRound = "080000"
</code></pre>

<p>The result should be a list of all filenames created  on or after or 08:00:00, however the resulting list is missing the "080000" file.</p>

<pre><code>filenames = ['CCN-200 data 130321090000.csv',
'CCN-200 data 130321100000.csv',
'CCN-200 data 130321110000.csv',
'CCN-200 data 130321120000.csv',
'CCN-200 data 130321130000.csv',
'CCN-200 data 130321140000.csv',
'CCN-200 data 130321150000.csv']
</code></pre>

<p>Why is the conditional not returning true on the = part of the condition and returning 'CCN-200 data 130321080000.csv' in my list? Please note I have only shown the basename here for clarity. </p>

<p>In your filenames <code>hhmmss</code> exist from index <code>19:25</code> rather than <code>19:24</code>. So the correct statement to get the <code>hhmmss</code> from filename is:</p>

<pre><code>filenames = [s for s in Allfilenames if os.path.basename(s)[19:25] &gt;= TOffRound]
</code></pre>

python