I am writing a program in python that prompts the user to enter a number of integer values. The program will need to store the integers, counts the frequency of each integer and display the frequency. (The number of elements to stored could be anything...5, 6, 7) I tried to start with 2 for nested loops first one just to add the numbers in the list but I do know hot to implement the counter
The output should be something like this print( Integer value, "occurs", frequency, "times)
input_list = int(input("Input the number of elements to be stored in a list: "))
list = []
for x in range(input_list):
list.append(input("Element - 0: "))
list.append(input("Element - 1: "))
list.append(input("Element - 2: "))
list.append(input("Element - 3: "))
list.append(input("Element - 4: "))
print("The frequency of all elements of the list:\n")
for y in counter(list)
counter = 0
input_len = int(input())
counts = []
for i in range(input_len):
numbers = map(int, input().split())
for number in numbers:
counts.append(number)
# Get frequencies
for count in set(counts):
print('frequency of', count, 'is', counts.count(count))