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

The owner of this website has banned the autonomous system number (ASN) your IP address is in (*****) from accessing this website

Charge Your Electric Car Just in 5 Minutes - New Achievement

پاکستانی ڈاکٹر کو کینیڈا کے بڑے سول اعزاز آرڈر آف کینیڈا سے نواز دیا گیا

Inspector ASF Seats announced through FPSC 2025

CM Punjab Asaan Karobaar Card Scheme

Graphic Designer Jobs in Forest Department , PAKISTAN 2025

Input the user name and print a greeting message using Python

Calculate and print each student average using Python

Describe in the light of Paget’s theory the cognitive and intellectual development of a child at different levels.

Discuss the different B.Ed programs currently being offered by AIOU and how are they contributing towards the vision of quality teacher education across the country ?