python编程 输入十个不同的数字,输出其中最大的数和次大的数。

求大神解答

#python2下的代码:

test=input('请输入一个数组:')
temp=sorted(test)
print '从小到大排序得:',temp
print '您输入的数组中,最大的数为:%g'%temp[-1]
print '您输入的数组中,第二大大的数为:%g'%temp[-2]

'------------------------------------'

#python3下的代码:

test=input('请输入一个数组:')
temp=[]
for i in test.split(','):
temp.append(int(i))
temp=sorted(temp)
print('从小到大排序得:',temp)
print('您输入的数组中,最大的数为:%g'%temp[-1])
print('您输入的数组中,第二大大的数为:%g'%temp[-2])追问

我的是3.6

追答

追问

好的 谢谢啊

温馨提示:答案为网友推荐,仅供参考
相似回答