python3实例(四)遍历列表中最大数

命题

输出多个输入中最大的元素

思路

  1. 输入元素个数
  2. 列表中输入元素,注意控制元素个数
  3. 输入列表中最大元素
#列表中元素个数
n=int(input("input the number digits: "))
#输入列表中元素,该段代码可用下行代替
#list[input("the list number:") for i in range(0,n))]
list=[]
for i in range(0,n):
    temp=input("the list number:")
    list.append(temp)
#输出结果
print("The list is :",list)
print("The max list number is :",max(list))

猜你喜欢

转载自blog.csdn.net/Amy8020/article/details/88557302