[Tutor] finding digit in string
Alan Gauld
alan.gauld at btinternet.com
Mon Oct 8 19:52:58 CEST 2012
On 08/10/12 17:43, Benjamin Fishbein wrote:
> I figured out a solution for the question I asked on here.
> To find the next digit (0-9) in a string, I use:
> text.find("0" or "1" or "2", etc.......)
Are you sure that worked? It doesn't for me on Python 2.7...
>>> s
'a string with 7 words in it'
>>> s.find('4' or '5' or '7')
-1
>>> s.find('7')
14
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list