Python Function That Counts Number of Alphabetic Characters, Keeps Track of How Many Times "e" Appears
<p>Write a function analyze_text that receives a string as input. The function should count the number of alphabetic characters (a through z, or A through Z) in the text and also keep track of how many are the letter 'e' (upper or lowercase).</p>

<p>The function should return an analysis of the text, something like this:</p>

<p>The text contains 240 alphabetic characters, of which 105 (43.75%) are ‘e’.</p>

<p>I need to make use of the isalpha function, which can be used like this:</p>

<pre><code>"a".isalpha() # =&gt; evaluates to True
"3".isalpha() # =&gt; evaluates to False
"&amp;".isalpha() # =&gt; False
" ".isalpha() # =&gt; False

mystr = "Q"
mystr.isalpha() # =&gt; True
</code></pre>

<p>The function should pass the following tests:</p>

<pre><code>from test import testEqual

text1 = "Eeeee"
answer1 = "The text contains 5 alphabetic characters, of which 5 
(100.0%) are 'e'."

testEqual(analyze_text(text1), answer1)

text2 = "Blueberries are tasteee!"
answer2 = "The text contains 21 alphabetic characters, of which 7
(33.3333333333%) are 'e'."

testEqual(analyze_text(text2), answer2)

text3 = "Wright's book, Gadsby, contains a total of 0 of that most
common symbol ;)"

answer3 = "The text contains 55 alphabetic characters, of which 0
(0.0%) are 'e'."

testEqual(analyze_text(text3), answer3)
</code></pre>

<p>So I tried:</p>

<pre><code>def analyze_text(text):

    text = input("Enter some text")
    alphaChars = len(text)

#count the number of times "e" appears
    eChars = text.count('e')

#find percentage that "e" appears
    eCharsPercent = eChars / alphaChars

    print("The text contains" + alphaChars + "alphabetic characters, of 
    which" + eChars + "(" + eCharsPercent + ") are 'e'.")

from test import testEqual

text1 = "Eeeee"
answer1 = "The text contains 5 alphabetic characters, of which 5
(100.0%) are 'e'."

testEqual(analyze_text(text1), answer1)

text2 = "Blueberries are tasteee!"
answer2 = "The text contains 21 alphabetic characters, of which 7
(33.3333333333%) are 'e'."

testEqual(analyze_text(text2), answer2)

text3 = "Wright's book, Gadsby, contains a total of 0 of that most
common symbol ;)"
answer3 = "The text contains 55 alphabetic characters, of which 0
(0.0%) are 'e'."

testEqual(analyze_text(text3), answer3)
</code></pre>

<p>As you can see, what I tried doesn't make use of the isalpha function (I don't know how / where to use it). Also, the function won't return whether or not the tests were passed. Visualize python doesn't support "test", and the text editor that I'm using in the book says that I have an indentation error (?) I don't know where to start - please help. </p>

<p><a href="https://i.stack.imgur.com/9qnKL.png" rel="nofollow noreferrer">Screenshot of Book Text Editor</a></p>

<p><strong>EDIT</strong>: Now receiving "TypeError: cannot concatenate 'str' and 'int' objects on line 12" (the line that starts with "print").</p>