The items in the list are movie titles with a 0 to 100 rating next to them. Here's part of it...
[(u'The Girl on the Train', 43),
(u'Keeping Up With The Joneses', 19),
(u'Ouija: Origin of Evil', 82),
(u'Long Way North (Tout en haut du monde)', 98),
(u'The Whole Truth', 29),
(u'Come And Find Me', 67),
(u'LEGO Jurassic World: The Indominus Escape', None),
(u'My Father, Die', 78)...]
I'd like to make a list of movies with scores at or above 60. Here is one of the things I've tried that didn't work, (this code will pull a little bit of data from RottenTomatoes website, FYI)...
import requests
r = requests.get('https://www.rottentomatoes.com/api/private/v2.0/browse?page=1&limit=30&type=dvd-top-rentals&services=amazon%3Bamazon_prime%3Bfandango_now%3Bhbo_go%3Bitunes%3Bn etflix_iw%3Bvudu&sortBy=popularity')
list = []
data = r.json()
for result in data["results"]:
list.append((result["title"], result["tomatoScore"]))
list2 = [i for i in list if i >=60]
print list2
I would also like to have all my movies titles with a score at or above 60 to be truncated to just the text of the movie title so I can have a program that enters them into search fields of websites. So if you know how that's done that would save me some additional feeling around in the dark. Maybe just a hint how that's done if asking how to do that is asking too much. Thank you!
Change
list2 = [i for i in list if i >= 60]
to
list2 = [i for i in list if i[1] >= 60]. # You need to compare only ratings
And don't call your list list
. It will overwrite python list
.