Now implement the solution yourself. Given a non-empty list of integers, return the largest value.
Examples:
- Input:
[3, 1, 4, 1, 5, 9]returns9 - Input:
[-7, -3, -10, -1]returns-1 - Input:
[42]returns42
Constraints: The list contains at least one integer. Values can be positive, negative, or zero.
Write a function find_max(nums) that returns the maximum value. Do not use the built-in max() function. Implement the logic yourself using a loop to practice the pattern.