Question

I have this segment of code:

count_words = input("Put in your favorite word, and then press the hidden button(SPOILER: IT'S ENTER!):")
split_Geonotes = Geonotes.replace ("\n", " "). split(".")
print (" Total number of words:", len (Geonotes.split() ) )

print("Total number of sentences:", len (Geonotes.split(".") ) )
print("Total number of periods:", Geonotes.count(".") )
print("you typed:", count_words)
print("There are:", Geonotes.count(count_words), "instances of", count_words)
split_Geonotes.sort()
print(split_Geonotes)
print("The number of elements in the HTML code:", len (split_Geonotes) )

for i in range(10):
    print(i)
    print(split_Geonotes(i) )

that begets the error shown in the title. According to the full error it happens at print(i) Can someone explain to me what's wrong? thank you.

Was it helpful?

Solution

It looks like you are trying to index the list split_Geonotes on the last line. You need to use square brackets [...] for this:

print(split_Geonotes[i])

Parenthesis (...) are for calling a function; when you place them after split_Geonotes, Python will try to call the list:

>>> lst = [1, 2, 3]
>>> lst(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>> lst[0]
1
>>>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top