IDNLearn.com makes it easy to find accurate answers to your specific questions. Discover thorough and trustworthy answers from our community of knowledgeable professionals, tailored to meet your specific needs.
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 contributing to our discussion. Don't forget to check back for new answers. Keep asking, answering, and sharing useful information. Your search for solutions ends at IDNLearn.com. Thank you for visiting, and we look forward to helping you again.