Hello seniors
The query I'm looking for now is
"Hello World, This is sample code" in the string
When you look for the word "sample",
I'm trying to pull out an index that corresponds to 'e' (last index of the word I'm looking for)
What should I do?
My head doesn't work even if I try to apply it as Googleing
mssql database
First, let's use a function to locate the word 'sample' in the entire sentence.
// Enter your code here
data = 'Hello World, This is sample code'
result = data.index('sample')
print('result : ', result)
Then you'll get the index where the sample is located If you think about the length of the word "sample" again, It's six letters
Then where is the last word, "e"? Is the index of the sample + the total length of the sample - 1 OK?
There may be a better way, but I think we can find it like this.
Note) Please note that the index starts from 0
© 2024 OneMinuteCode. All rights reserved.