I'm very new to Python. I understand that the find function takes a string p and a substring s and returns the index at which s shows up in p. But if I had something like
p = 'abc'
text = 'aaaabbaac'
text.find(p)
Would it be possible to write a method that allows me to set the wildcard to b and still return the index at which a and c match, instead of returning -1?
I'm using this in a class that has two methods, the find method and a "setwildcard" method which takes a character and does what I described above.
Aucun commentaire:
Enregistrer un commentaire