Pythonic way to find integer in list of strings
<p>I have an array as follows:</p>

<pre><code>hour = ['01','02','12']
</code></pre>

<p>and I want </p>

<pre><code>h = 1
str(h) in hour
</code></pre>

<p>to return <code>True</code>. What would be the most "Pythonic" way to do this? I could of course pad <code>h</code> with a zero, but is there a better way?</p>

<p>A good rule of thumb is that the type and structure of data should reflect the model you have in mind. So, if your model is that hours are integers in the range 1..24, or whatever, you should model them that way:</p>

<pre><code>hours = [ int(hr) for hr in hour ]
</code></pre>

<p>then things like:</p>

<pre><code>h in hours 
</code></pre>

<p>become clean and obvious.</p>

python arrays