Explore a vast range of topics and get informed answers at IDNLearn.com. Find the solutions you need quickly and accurately with help from our knowledgeable community.
Sagot :
Answer:
filename = input("Enter file name: ")
movie_container = list()
with open(filename, "r") as movies:
content = movies.readlines()
for movie in content:
holder = movie.split("\t")
movie_container.append((holder[0], holder[1], holder[2], holder[3]))
movie_container = sorted(movie_container, key= lambda movie: movie[0])
for movie in movie_container:
movie_stars = movie[3].split(",")
name_split = [names.split(" ") for names in movie_stars]
movie_stars.clear()
name_split = sorted(name_split, key= lambda names: names[1])
for name in name_split:
full_name = " ".join(name)
print( full_name)
movie_stars.append(full_name)
movie[3] = movie_stars
print(movie_container)
Explanation:
The python code uses the open function to open and read in the input file from the standard user prompt. The title of the movies and the stars are all sorted alphabetically and display at the output.
Thank you for using this platform to share and learn. Keep asking and answering. We appreciate every contribution you make. IDNLearn.com is your reliable source for answers. We appreciate your visit and look forward to assisting you again soon.