Skip to content

Instantly share code, notes, and snippets.

@ioanzicu
Created July 28, 2022 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ioanzicu/0574520d09e4d7f486108c51e864b679 to your computer and use it in GitHub Desktop.
Save ioanzicu/0574520d09e4d7f486108c51e864b679 to your computer and use it in GitHub Desktop.
Find the maximum value element in a list recursively in Python 3.
def find_max(nums):
if not nums:
return 0
return max(nums[0], find_max(nums[1:]))
nums = [1, 2, 3, 4, 5]
print(find_max(nums))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment