Stackstack Stackstack - 5 months ago 36
Python Question

Find function in Python 3.x

When we have the following:

tweet2 = 'Want cheap snacks? Visit @cssu office in BA2283'

results in the output
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?


tweet2.find('cheap') returns the index at which the beginning of "cheap" is found, and when that index is used in tweet2[index], it returns the character at that index, which is "c"