This code pulls a little bit of data from RottenTomatoes. (Movie titles and tomato scores.) I'd like to now remove the the last 6 and first 3 characters from each item so only the movie title remains. I know that what I'm trying now would only remove the numbers if it worked. I don't know if what I'm trying is in the ballpark but it's saying I have a tuple when I thought I had a list so it may be more complicated than I understand.
Example of what I have...
[(u'Ouija: Origin of Evil', 82), (u'Long Way North (Tout en haut du
monde)', 98), (u'Come And Find Me', 67), (u'My Father, Die', 78),
(u"Roger Corman's Death Race 2050", 100), ...
What I'd like done to it (as a permanent change to the list & not just printed in a new way)...
[Ouija: Origin of Evil, Long Way North (Tout en haut du monde), Come
And Find Me, My Father, Die, Roger Corman's Death Race 2050"...
My code...
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%3Bnetflix_iw%3Bvudu&sortBy=popularity')
movies = []
data = r.json()
for result in data["results"]:
movies.append((result["title"], result["tomatoScore"]))
list2 = [i for i in movies if i[1] >=60]
list2 = ' '.join(list2).replace('1''2''3''4''5''6''7''8''9','').split()
print list2
The error...
(venv) My-MacBook-Pro:tor Me$ python bs.py
Traceback (most recent call last):
File "bs.py", line 16, in <module>
list2 = ' '.join(list2).replace('1''2''3''4''5''6''7''8''9','').split()
TypeError: sequence item 0: expected string, tuple found
(venv) My-MacBook-Pro:tor Me$