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>You should consider reading python documentation on string methods and lists  </p>

<pre><code># define string variable tweet2
tweet2 = 'Want cheap snacks? Visit @cssu office in BA2283'
# find position of substring 'cheap', which is 5 (strings has 0-based indices in python
n = tweet2.find('cheap')
# print 5th element of string, which is 'c'
print(tweet2[n])
</code></pre>

python python-3.x