Let’s play a bit with randomly generated lists.
Count the Max from the list
The task: Let’s generate random list of 10 elements and count of maximum values in the list.
import random arr = [] for i in range(0, 10): arr.append(random.randint(0, 10)) max = arr[0] count = 0 for x in arr: if x == max: count += 1 elif x > max: count = 1 max = x print(arr) print("The maximum value is: {0}; and the count: {1}".format(max, count))