# 在数字列表中找到最大（最大，最大）的数字

##### 问题描述投票：0回答：7

python numbers max
##### 7个回答
155

``max()``

``````highest = max(1, 2, 3)  # or max([1, 2, 3]) for lists
``````

18

``max()``

``````print max(1, 2, 3)
``````

``````list = [1, 2, 3]
print max(list)
``````

17

``max()``

``````a = [1,2,3,4,6,7,99,88,999]
max_num = 0
for i in a:
if i > max_num:
max_num = i
print(max_num)
``````

``````print(a.index(max_num))
``````

max() 函数返回具有最高值的项，或 iterable 中具有最高值的项

``````a = (1, 5, 3, 9)
print(max(a))
>> 9
``````

``````x = max("Mike", "John", "Vicky")
print(x)
>> Vicky
``````

11

``max()``

``````>>> l = [1, 2, 5]
>>> max(l)
5
>>>
``````

2

``max``

``````print(max([9, 7, 12, 5]))

# prints 12
``````

2

``````sorted(l,reverse=True)
``````

``````l = [1, 2, 3]
sort=sorted(l,reverse=True)
print(sort)
``````

``````[3,2,1]
``````

``````print(sort[0])
``````

``````3
``````

``````print(sort[1])
``````

-7

``````    #Ask for number input
first = int(raw_input('Please type a number: '))
second = int(raw_input('Please type a number: '))
third = int(raw_input('Please type a number: '))
fourth = int(raw_input('Please type a number: '))
fifth = int(raw_input('Please type a number: '))
sixth = int(raw_input('Please type a number: '))
seventh = int(raw_input('Please type a number: '))
eighth = int(raw_input('Please type a number: '))
ninth = int(raw_input('Please type a number: '))
tenth = int(raw_input('Please type a number: '))

#create a list for variables
sorted_list = [first, second, third, fourth, fifth, sixth, seventh,
eighth, ninth, tenth]
odd_numbers = []

#filter list and add odd numbers to new list
for value in sorted_list:
if value%2 != 0:
odd_numbers.append(value)
print 'The greatest odd number you typed was:', max(odd_numbers)
``````