Thanks to visit codestin.com
Credit goes to www.scribd.com

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

Practical 04 Complete-1

This document outlines a practical assignment for a Python Programming course, specifically focusing on a program to remove the 'i' th occurrence of a specified word from a list. It includes a code snippet that defines a function to achieve this and provides an example with a list of names. The output of the program is not explicitly stated in the document.

Uploaded by

syediliyas8282
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)
8 views2 pages

Practical 04 Complete-1

This document outlines a practical assignment for a Python Programming course, specifically focusing on a program to remove the 'i' th occurrence of a specified word from a list. It includes a code snippet that defines a function to achieve this and provides an example with a list of names. The output of the program is not explicitly stated in the document.

Uploaded by

syediliyas8282
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 :- Syed Iliyas PRN No :- 24025081245527

DOP:- __/__/2025 DOC:- __/__/2025

Practical no :- 4

Aim :- Program to remove the ―i‖ th occurrence of the given word in a list
where words repeat.

Code :-

def remove_ith_occurrence(lst, word, i):

count = 0

for index in range(len(lst)):

if lst[index] == word:

count += 1

if count == i:

del lst[index]

return lst

return lst

names = ["Iliyas", "Onkar", "Iliyas", "Tejas", "Iliyas", "Vishwajeet"]

Practical No 4 Page 1
BTCOL406 :-Python Programming

name_to_remove = "Iliyas"

occurrence = 2

print(remove_ith_occurrence(names, name_to_remove, occurrence))

Output :-

Practical No 4 Page 2

You might also like