In this Python array examples Ask the user to Enter five integeres, then Store them in an array. After that sort the list and display them in reveres order.
Let's write the program for the above
from array import * nums =array('i',[]) for i in range (0,5): num = int(raw_input("Enter a Number: ")) nums.append(num) nums = sorted(nums) nums.reverse() print(nums) |
Output:
Enter a Number: 21 |
Article Contributed By :
|
|
|
|
713 Views |