"""File: movie.py Purpose: Store info on a movie as a list Run: Python movie.py Input: Title, year, director, stars and rating of a movie Output: The info the user entered """ #---------------------------------------------------------------------- def create_stars(): """Get a list of stars from the user and return this""" stars = [] print "Enter the stars (empty line to stop)" star = raw_input(" ") while star != "": stars.append(star) star = raw_input(" ") return stars #---------------------------------------------------------------------- def create_movie(): """Store information on a movie as a dictionary""" new_movie = [] title = raw_input("What's the title?\n ") new_movie.append(title) year = int(raw_input("What's the year?\n ")) new_movie.append(year) director = raw_input("Who's the director?\n ") new_movie.append(director) stars = create_stars() new_movie.append(stars) rating = int(raw_input("Rating?\n ")) new_movie.append(rating) return new_movie #---------------------------------------------------------------------- def print_movie(movie): """Print info on a movie that's stored as a dictionary""" print print "Movie:" print " Title: ", movie[0] print " Year: ", movie[1] print " Director: ", movie[2] print " Stars: " for s in movie[3]: print " ", s print " Rating: ", movie[4] #---------------------------------------------------------------------- # Main program # Only execute the main program if this file is *not* imported into another if __name__ == "__main__": movie = create_movie() print_movie(movie)