<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 23/07/2010 15:22, Vineeth Rakesh wrote:
<blockquote
cite="mid:AANLkTinBt5VMu=M0FnJwu1G=CPU2eApmDEd55fm0oDF+@mail.gmail.com"
type="cite">Hello all, <br>
<br>
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?<br>
<br>
Thanks<br>
Vin <br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Tutor maillist - <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
To unsubscribe or change subscription options:
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
</pre>
</blockquote>
<br>
<tt>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.</tt><br>
<pre class="moz-signature" cols="72">--
Kind Regards,
Christian Witts
</pre>
</body>
</html>