Skip to content

Commit b4a381f

Browse files
authored
Merge pull request #252 from psmaker/patch-4
Update Exercises.rst
2 parents b88ad6b + 2073bc6 commit b4a381f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

_sources/Strings/Exercises.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,12 @@ Exercises
156156
if achar == 'e':
157157
numberOfe = numberOfe + 1
158158

159-
percent_with_e = (numberOfe / totalChars) * 100
160-
print("Your text contains", totalChars, "alphabetic characters of which", numberOfe, "(", percent_with_e, "%)", "are 'e'.")
161-
159+
if totalChars != 0:
160+
percent_with_e = (numberOfe / totalChars) * 100
161+
print("Your text contains", totalChars, "alphabetic characters of which", numberOfe, "(", percent_with_e, "%)", "are 'e'.")
162+
else:
163+
print("There were no characters in the input string p")
164+
return (numberOfe)
162165

163166
p = '''
164167
"If the automobile had followed the same development cycle as the computer, a

0 commit comments

Comments
 (0)