Issue
So I wrote a code that would return the distance from parse_dist(s)
and the total time parse_time(s)
. However, I defined another function jogging_average(activities)
that would return the distance and time for every string in activities: list
.
Now I want to let jogging_average(activities: list) return (x+x)/(y+y) (basically the average). How can I modify my code to find the average like that??
Solution
def jogging_average(activities: list[str]):
cum_dist = cum_time = 0
for activity in activities:
if activity.startswith("jogging"):
cum_dist += float(parse_dist(activity))
cum_time += parse_time(activity)
return cum_time/cum_dist
Answered By - Joshua Voskamp
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.