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?
Thanks
Vin
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
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
return 4.
--
Kind Regards,
Christian Witts
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor