Westonci.ca is the premier destination for reliable answers to your questions, provided by a community of experts. Explore in-depth answers to your questions from a knowledgeable community of experts across different fields. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.
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 visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. We appreciate your time. Please come back anytime for the latest information and answers to your questions. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.