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