[Tutor] position of an element in list:
cwitts at compuscan.co.za
Fri Jul 23 15:38:20 CEST 2010
On 23/07/2010 15:22, Vineeth Rakesh wrote:
> Hello all,
> How to return the position of a character in a string. Say I have str1
> = "welcome to the world" if i want to return the position of the first
> occurrence of "o" how to do it?
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
Strings have a function called index, which take a string argument which
is what you're looking for. So you can do str1.index('o') which would
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor