i want to recommend movie
withPinkkkyy

if user input genre/type of movie they will show title of movie and rating
i want to know how to write
i'm doing if they input genre that same in list_in(genre of movie) they will collect in the same list(genre[])

You are viewing a single comment. View All
Codejira

@withPinkkkyy Yes,there is a dict. It's just not obvious, as I took a short cut. Inspect line 42:
option = {num+1:opt for num, opt in enumerate(from_list)}

  • the new dict is called `option'
  • num+1:opt are the key:value pairs, with num starting at 0, but I want 1 as first key.
  • (num, opt) is a tuple returned by enumerate(). See documentation.

The notation with the curly brackets is called dict comprehension. It is a short cut for

Note: Looking at the documentation link above I just learned that enumerate has an optional start parameter, preferable to num+1.

Tip: Also look into list comprehension. A cool thing to have in your toolbox.