[Tutor] position of an element in list:

Alan Gauld alan.gauld at btinternet.com
Fri Jul 23 19:09:28 CEST 2010


"Vineeth Rakesh" <vineethrakesh at gmail.com> wrote

> 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?

Others have answered but don't forget Python's help() facility.

>>> help(str)

Would have probably got your answer a lot faster than posting a
question and waiting for replies.

We don't mind helping but for these kinds of question its usually
quicker to try a help(), dir() or even a Google search first. It saves
your time and ours.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list