Discussions Events Study Material Jobs
Input a list and create a dictionary where keys are elements and values are their frequency using Python - Uniwaly

Explore Diverse Conversations

Input a list and create a dictionary where keys are elements and values are their frequency using Python

Posted By: UmairMehmood Published On: 13 June 2025 At: 11:51 AM

Count Frequency of Elements in List
elements = []
for i in range(5):
    item = input(f"Enter item {i+1}: ")
    elements.append(item)
frequency = {}
for item in elements:
    if item in frequency:
        frequency[item] += 1
    else:
        frequency[item] = 1

# Result print karna
print("\nElement frequencies:")
for key in frequency:
    print(f"{key}: {frequency[key]}")


Tags:

python dictionary python dictionary frequency python code
Login to like

Posted By:

Author Profile

UmairMehmood

11 days ago

Join the conversation!

Login to Comment

Discover More Articles

What is meant by continuing education? Highlight its significance for a society and individual.

Create a tuple of 6 items and print its length using len() function Using Python

Palm Reading in Islam : Is It Permissible? A Faith-Centered Guide

Pension New Method Explained - Which Employees Not Eligible For Pension ?

Indian BSF soldier arrested on Pakistani soil by Pak Rangers

National University of Sciences and Technology ( Nust ) Admission Process

Punjab Danish School New Jobs 2025 - Non Academic Staff Required

Social Mobilizer - The Urban Unit Jobs 2025

University of Veterinary & Animal Sciences UVAS Swat

Al Barik Bank Jobs 2025 in Pakistan - Apply Now