0% found this document useful (0 votes)
4 views2 pages

5 TH

The document outlines a practical assignment for a Python Programming course at Gramin Technical And Management Campus, focusing on a program that counts the occurrence of each word in a given string. It includes a code snippet that prompts the user to input elements into a list, counts occurrences of a specified word, and updates the list accordingly. The output displays the number of repetitions, the updated list, and the distinct elements from the original list.

Uploaded by

ranjereanamika3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

5 TH

The document outlines a practical assignment for a Python Programming course at Gramin Technical And Management Campus, focusing on a program that counts the occurrence of each word in a given string. It includes a code snippet that prompts the user to input elements into a list, counts occurrences of a specified word, and updates the list accordingly. The output displays the number of repetitions, the updated list, and the distinct elements from the original list.

Uploaded by

ranjereanamika3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

BTCOL406 :-Python Programming

Gramin Technical And Management Campus Nanded Department of computer


Engineering (Degree)

Subject Name/code :- BTCOL406 Python Programming

Student Name :- Jadhav Shreya Balaji PRN No :-23025081245085

DOP:- DOC:-

Practical No :-05

Aim:- Program to count the occurrence of each word in a given string sentence.
Code:-
a=[]
n= int(input("Enter the number
of elements in list:"))
for x in range(0,n):
element=input("Enter
element" + str(x+1) + ":")
a.append(element)
print(a)
c=[]
count=0
b=input("Enter word to remove:
")
n=int(input("Enter the
occurrence to remove: "))
for i in a:
if(i==b):
count=count+1
if(count!=n):
c.append(i)
else:
c.append(i)
if(count==0):
print("Item not found ")
else:
print("The number of
repetitions is: ",count)
print("Updated list is: ",c)
print("The distinct elements are:
",set(a))

Output:-

You might also like