[Tutor] unable to use find(), index()
Steven D'Aprano
steve at pearwood.info
Thu Dec 8 12:42:27 CET 2011
surya k wrote:
> I am using the following code
> astr = "foobar"str1 ="foo"astr.find(str1, beg=0, end=3)
You have mangled the code in your email and lost line breaks. Fortunately this
is simple enough to fix:
astr = "foobar"
str1 ="foo"
astr.find(str1, beg=0, end=3)
Please take more care to post code in PLAIN TEXT, not html "rich text", which
may mangle line breaks and break the code.
> 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!
Did you read the error message?
"find() takes no keyword arguments"
This means just what it says: the find method does not take keyword arguments.
Do you understand what keyword arguments are?
# Wrong, will not work:
astr.find(str1, begin=23, end=42)
# Right, will work:
astr.find(str1, 23, 42)
--
Steven
More information about the Tutor
mailing list