Since you want index in x?. You need to use x.index(o) where searches for o in x.
x = 'Poisson geometry plays an important role in noncommutative geometry.'
y = 'u'
i = 0
while i == 0:
for o in x:
if o == y:
print(y, "is first seen in index = ", x.index(o))
i += 1
The correct way to write it is without a loop:
x = 'Poisson geometry plays an important role in noncommutative geometry.'
y = 'u'
print(y, "is first seen in index = ", x.index(y))
output:
u is first seen in index = 51
If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch