nums = [10, 90, 80, 60, 50]
maxone = 0
maxtwo = 0
for x in nums:
if(maxone < x):
maxtwo = maxone
maxone = x
elif (maxtwo < x):
maxtwo = x
print "First two largest numbers"
print "First largest number:", maxone
print "First largest number:", maxtwo
output:
maxone = 0
maxtwo = 0
for x in nums:
if(maxone < x):
maxtwo = maxone
maxone = x
elif (maxtwo < x):
maxtwo = x
print "First two largest numbers"
print "First largest number:", maxone
print "First largest number:", maxtwo
output:
First two largest numbers First largest number: 90 First largest number: 80
No comments:
Post a Comment