Computer Science, asked by joelchris3007, 5 months ago

Write Insert(Place) and Delete(Place) methods in python to add Place and
Remove Place considering them to act as Insert and Delete operations on a List
storing names of cities. Also print the details after every operation in the
ascending order

Answers

Answered by jai696
1

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

def Insert(place, places):

places += [place]

def Delete(place, places):

places[:] = [item for item in places if item != place]

places = []

cities = ["Panjim", "Margao", "Mapusa", "Quepem"]

for place in cities:

Insert(place, places)

print(f"Added '{place}' in places!")

print("Added places", places, "\n")

for place in cities:

Delete(place, places)

print(f"Removed '{place}' from places!")

print("After removing:", places)

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions