fork download
  1. def text_counter(string):
  2. e_count, word_count = 0, 0
  3. is_word, is_e = False, False
  4. for char in string:
  5. is_e = is_e or (char == 'е')
  6. if is_word:
  7. if char in [' ', '.', '!', ',']:
  8. e_count += int(is_e)
  9. is_word, is_e = False, False
  10. elif char not in [' ', '.', '!', ',']:
  11. is_word = True
  12. word_count += 1
  13. if char is string[-1]:
  14. e_count += int(is_e)
  15. return word_count, e_count
Success #stdin #stdout 0.02s 9020KB
stdin
Standard input is empty
stdout
Standard output is empty