repl.it
@TonySiu/

Filter Movies

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Netflix = [("Tarzan",2),("Simba",9),("Baby",7),("Batman",3)]

def filter_movies(movies, ratings):
  movie_bucket = [] #Counter Bucket

  for i in movies: #Iterates all tuples within the list
    if i[1] >= ratings: #Check 2nd(int) position of tuple
      movie_bucket.append(i[0]) #Checks and adds name to counter list then goes back to outermost indent of for:
  return movie_bucket #Returns the counter bucket after loop exit

print(filter_movies(Netflix,3))




# NEED HELP WITH THIS PIECE OF CODE BELOW THE CURRENT COMMENT




fruits = ["banana","apple","orange","pear"]


def fruit_basket(fruit, letter):
  basket = []

  for i in fruit:
    for j in i:
      if j == letter:
        basket.append(i)
        break
        
  return basket

print(fruit_basket(fruits,'z'))