On 2011/12/08 01:19 PM, surya k wrote:
I am using the following code
astr = "foobar"str1 ="foo"astr.find(str1, beg=0, end=3)
This is showing the following error
Traceback (most recent call last): File "<interactive input>", line 1,
in<module>TypeError: find() takes no keyword arguments
I even tried by importing "string" module, but it isn't working.
This same problem with find()
Could you please help me!
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Your traceback message gives you the reason it's not working, `find()
takes no keyword arguments`. The function only takes positional
arguments so if you just write `astr.find(str1, 0, 3)` it will work as
you expect it to.
>>> help(''.find)
Help on built-in function find:
find(...)
S.find(sub [,start [,end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within s[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
--
Christian Witts
Python Developer
//
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor