Skip to content

Commit 3f4798e

Browse files
committed
2 parents 51e3588 + b4a381f commit 3f4798e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

_sources/Lists/Exercises.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Exercises
201201
.. activecode:: lst_q5_answer
202202

203203
def max(lst):
204-
max = 0
204+
max = lst[0]
205205
for e in lst:
206206
if e > max:
207207
max = e

_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)