[Tutor] unexpected error

Jerry Lake jerryl@europa.com
Tue, 9 Oct 2001 10:10:26 -0700


I'm reading through the eBook
"how to think like a computer programmer" python version
and I'm following along in chapter 7.9 "The string Module"

however I get this error from this code, any ideas ? the output is
completely not expected

<snip>
#!/usr/bin/python2

import string

fruit = "banana"
count = 0
index = 0
for char in fruit:
  if char == 'a':
    count = count + 1
print count

indeX = string.find(fruit, "a")
print indeX
</snip>

<output>
this is a
14
1
3
Traceback (most recent call last):
  File "./fortest.py", line 13, in ?
    indeX = string.find(fruit, "a")
AttributeError: 'string' module has no attribute 'find'
</output>

Jerry Lake
Interface Engineering Technician