컴퓨터/Python

Python max() | 파이썬 최대값

sayyesdoit 2023. 2. 1. 20:05
# Finding the maximum value in a list
numbers = [1, 2, 3, 4, 5]
print(max(numbers))
# Output: 5

# Finding the maximum value of two arguments
print(max(3, 7))
# Output: 7

# Finding the maximum value of three or more arguments
print(max(1, 5, 7, 2))
# Output: 7

# Finding the maximum value in a string
letters = "hello"
print(max(letters))
# Output: 'o'