Bit of an odd one I've got here...
Basically say I have a list with lists inside of it.
ratings = [
# ''' 1 star '''
["Strangers on a Train", "Anchorman", "Saw", "Suicide Squad"],
# ''' 2 star '''
["Shutter Island", "Shaun of the Dead", "Scream", "Indiana Jones"],
# ''' 3 star'''
["Goodfellas", "Mr Bean", "The Ring", "Dark Knight"],
# ''' 4 star'''
["Scarface", "Hot Fuzz", "Nosferatu", "Die Hard"],
# ''' 5 star'''
["Pulp Fiction", "Airplane", "The Omen", "Deadpool"]
]
Obviously this is a list of movies, and inside the list is 5 lists giving each of the movies a rating out of 5, although this context is quite useless.
def rating():
if userInfo[7] == "1":
return range(5)
elif userInfo[7] == "2":
return range(2, 5)
elif userInfo[7] == "3":
return range(3, 5)
elif userInfo[7] == "4":
return range(4, 5)
else:
return range(5, 5)
Here is a function where essentially a range is returned depending on what minimum rating of film they would like to see is. So say their minimum rating is 4, they will only see films of rating 4 and 5.
say they have a list of movies
movies = ["Strangers on a Train", "Anchorman", "Shutter Island",
"Shaun of the Dead", "Goodfellas", "Mr Bean",
"Scarface", "Hot Fuzz", "Pulp Fiction", "Airplane"]
Now I want to remove all the movies from this list which are not of rating 4 or above.
I tried
new = []
for item in movies:
if item not in in ratings[rating()]:
new.append(item)
but this will not work as I cannot use a range to search through multiple lists inside the big list as it needs to be an integer.
I understand this is a huge post for such a small problem but my brain is dying and I have been trying to do this for hours and I want to sleep but need to do this.