Find function in Python 3.x
<p>When we have the following: </p>

<pre><code>tweet2 = 'Want cheap snacks? Visit @cssu office in BA2283'
</code></pre>

<p><code>print(tweet2[tweet2.find('cheap')])</code> results in the output <code>'c'</code> and I cant wrap my head around how it does this. I tried the visualizer and it didn't show anything. Could anyone please explain?</p>

<p><code>find</code> returns an index, not a slice.</p>

<p>If you want the full string you can get it like so:</p>

<pre><code>to_find = 'cheap'
ind = tweet2.find(to_find)
print(tweet2[ind:ind+len(to_find)])
</code></pre>

python python-3.x