string character count

noydb jenn.duerr at gmail.com
Tue Jun 30 13:27:57 EDT 2009


If I have a string for a file name such that I want to find the number
of characters to the left of the dot, how can that be done?

I did it this way:
x = "text12345.txt"
dot = x.find('.')
print dot

Was curious to see what method others would use - helps me learn.  I
guess I was most curious to see if it could be done in one line.

And, how would a char count be done with no dot -- like if the string
were "textstringwithoutdot" or "no dot in text string"?



More information about the Python-list mailing list