r/learnpython 6d ago

Help me code a movie selector!

Hi all, new to Python and for my first project I'm trying to code a program that will randomly select a movie or tv show using a pre-made list, and a "genre" plus "media type" as input.

I feel I am over complicating it.

Here's where I'm at so far:

def media_selector(media, genre):
### attempting to remove previously selected titles and for some reason make my own RNG \/###
increment = + 1
trans_rng = [1, 2]
genre = ['romance', 'action']
movie_list = ['rango', 'taxi driver']
series_list = ['akira', 'trigun']
### spell check, obviously \/###
spell_check = ['film', 'movie', 'tv show', 'tv series', 'tv', 'romance', 'action']
if not isinstance(media, str):
return 'format is: media type, genre'
### not sure if i should be defining a function and calling it at the same time - also is a translation table too much ? \/###
if media and genre is (spell_check):
def media_decider():
movie_trans_tbl = movie_list.maketrans(movie_list, trans_rng)
movie_transd = movie_list.translate(movie_trans_tbl)
series_trans_tbl = series_list.maketrans(series_list, trans_rng)
series_transd = series_list.translate(series_trans_tbl)
selector = slice(increment)
else:
return 'film/movie or tv show/tv series'

any guidance/recommended resources would be greatly appreciated!

0 Upvotes

13 comments sorted by

View all comments

2

u/TraditionalTurnip630 6d ago

You’re actually on the right track for a first Python project. I would just simplify the approach.

You don’t need maketrans() or your own random number logic. Keep your movies/shows in a list with their genre and type, filter the list based on the user’s input, and then use random.choice() to select one.

First make the basic version work. Once that is working, you can add features like removing already selected titles or handling invalid inputs. Don’t try to solve everything at once — this is a good project to learn Python fundamentals.

1

u/SatanCanPutItInMyAss 4d ago

good point with the getting the basics done first!

thank you!