May-06-2017, 11:20 AM
listb is all the movies, and it's still a bad variable name. Giving your variables descriptive names will not only help us understand your code and thus help you, it will also help you see for yourself where the problems are in your code. Back to listb:
favlist = list.append(listb)What you are doing is appending a list of all the movies to the list of all the movies, which isn't very useful. Also, the result of that is None. The append method changes the list in place, and doesn't return anything (this is a difference between list methods and string methods. So, an example with actual lists:
Output:>>> users = ['ichabod801', 'snippsat', 'Mekire']
>>> coders = users
>>> people = users.append(coders)
>>> print(people)
None
>>> print(users)
['ichabod801', 'snippsat', 'Mekire', ['ichabod801', 'snippsat', 'Mekire']]
So, if you want to do something with the matching movies, you should save them in a list:matches = [] letter = input('Search title starting with the letter: ') # input is already returning a str, you don't need to convert it. for movie in movies_list: if movie.startswith(letter): matches.append(movie) print(movie)Now you've got a list of movies matching the last criteria. If you have a list of favorite movies (call it favorites), you can use the extend method to add the items in the matches list to the favorites list.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures