i am using python 2.5.2. The following code not working.
def findValue(self, text, findText):
     index = text.find(findText)
     print index
Although the findText is present in text, but it still returns None.
I have printed the values of text and findText and they are present. 
Edit: I have fixed the issue.
The problem was i am calling code like
for i in arr:
      self.findValue(i,"someText")
As type of i is insta开发者_开发问答nce so this does not work. I have just changed it to:
self.findValue(str(i),"someText")
You aren't returning a value from your function, you are only printing it. This means that the return value for the function will be None.
Try adding return indexat the end of your code.
def myfind(self, text, findText):
     index = text.find(findText)
     return index
Python doesn't automatically return the last variable, you need to explicitly use return index
And If the .find is failing, it should return -1 instead of None, So most probably, problem is in your return part, not in the .find
I have fixed the issue.
The problem was i am calling code like
for i in arr: 
      self.findValue(i,"someText") 
As type of i is instance so this does not work. I have just changed it to:
self.findValue(str(i),"someText") 
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论