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

Schedule of assessment for the post of Enforcement officer and Investigation officer 2025

فلم پی کے میں دکھایا گیا ایک سین حقیقت میں تبدیل

NIU - NUR International University - Admission Process

Government University and Collage Faisalabad ( GCUF ) Admission Criteria All Departments

Create a dictionary with keys as subjects and values as marks. Print marks for a given subject using Python

Use a dictionary where keys are student names and values are lists of 3 marks Using Python

Syngenta Pakistan Apprenticeship Program 2025

National University of Computer and Emerging Sciences Admission Process

University of Veterinary & Animal Sciences UVAS Swat

Explain with specific example the relationship of higher education with employment situation in the developing countries.