I have been searching for a solution for this error for a while but the solutions that have helped others have not been much help for me.
Here is the code that I've wrote.
def main():while True:userInput()characterCount(userInput)middleLetter()spaceCount()letterReplace()displayOutput()def userInput():sentence = str(input('Enter a sentence at least 10 letters long, or type STOP to quit:')) if sentence == 'STOP':quit()return sentencedef characterCount(sentence):characterCount = len(sentence) - sentence.count(' ')if characterCount < 10:print('Sorry that is less than 10 letters')return characterCountdef middleLetter(sentence):sentence = len(sentence)/2middleLetter = [sentence +1]return middleLetterdef spaceCount(sentence):spaceCount = sentence.count(' ')return spaceCountdef letterReplace(sentence):letterReplace= sentence.replace("a", "&")return letterReplacedef displayOutput(characterCount,middleLetter,spaceCount,letterReplace):print('Number of letters: '(characterCount))print('Middle letter: '(middleLetter))print('Spaces counted: '(spaceCount))print('Sentence with letter replaced: '(letterReplace))main()
The problem I have is that when I run the program I get the error.
Traceback (most recent call last):File "C:\Users\wood\Desktop\Software design\Program 4\program3_4QuinnWood.py", line 59, in <module>main()File "C:\Users\wood\Desktop\Software design\Program 4\program3_4QuinnWood.py", line 18, in maincharacterCount(userInput)File "C:\Users\wood\Desktop\Software design\Program 4\program3_4QuinnWood.py", line 32, in characterCountcharacterCount = len(sentence) - sentence.count(' ')
TypeError: object of type 'function' has no len()
Most of the times I have seen this error is because of a int being used instead of a string but I can not see what would be causing this error. Any help would be appreciated.
Using some of the given suggestions I have fixed the original error but now when I try to run it I receive the error.
Traceback (most recent call last):File "C:\Users\wood\Desktop\Software design\Program 4\program3_4QuinnWood.py", line 59, in <module>main()File "C:\Users\wood\Desktop\Software design\Program 4\program3_4QuinnWood.py", line 22, in maindisplayOutput(characterCount,middleLetter,spaceCount,letterReplace)File "C:\Users\wood\Desktop\Software design\Program 4\program3_4QuinnWood.py", line 53, in displayOutputprint('Number of letters:'(characterCount))
TypeError: 'str' object is not callable