Guest User

Untitled

a guest
Apr 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. def analyze_text(text):
  2. letter_count = 0
  3. alphas = 0
  4. for c in text:
  5. if c == "e" or c == "E":
  6. letter_count += 1
  7. if c.isalpha():
  8. alphas += 1
  9.  
  10.  
  11. ans1 = "The text contains {0} alphabetic characters, of which {1} ({2}%) are 'e'."
  12. return ans1.format(alphas, letter_count, float(letter_count / alphas * 100))
Add Comment
Please, Sign In to add comment