0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 7
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
The built-in float() function can create a numeric floating point value of negative infinity. Instead of initializing a base value like 0
or -100000
, we can use float("-inf")
to represent negative infinity. Because every value will be greater than negative infinity, we can use it as a starting point to help us achieve our goal of finding the max value.
negative_infinity = float("-inf")
positive_infinity = float("inf")
Our players want a way to see their strongest attack from their last combat. Let's add another function to analyze data from our combat log.
Complete the find_max
function that looks at each number in the nums
list and returns the maximum value. If no maximum is found, it just returns negative infinity. I've added it for you as the starting value of max_so_far
.
Here's an example of how your find_max
function should work:
max_val = find_max([100, 10, 22])
print(max_val)
# 100
max_so_far
is just that, the highest number from the list so far. It starts as negative infinity because any and every number is larger than negative infinity.
Focus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution