[x for x in range(5)]
my_list = [x * 2 for x in range(5)]
print(my_list)
[0, 2, 4, 6, 8]
# what is the equivalent way of doing this with a for loop?
[x**2 for x in range(10)]
my_list = []
for x in range(10):
my_list.append(x**2)
print(my_list)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
# colon is now no longer needed
[x**2 for x in range(10):]
SyntaxError: invalid syntax (<ipython-input-8-f0eb79aba811>, line 2)
# title case
"This Title of Greatness"
"This Title of Greatness".lower().title()
# An example with cities
# The task is to capitalize every city in the list
# Approach 1: the usual for loop
cities = ['jakarta', 'kuala lumpur', 'singapore', 'manila']
# three lines with the usual for loop
cities_capitalized = []
for city in cities:
cities_capitalized.append(city.title())
print(cities_capitalized)
['Jakarta', 'Kuala Lumpur', 'Singapore', 'Manila']
# Approach 2
# A more elegant way to achieve the same thing using list comprehension
cities = ['jakarta', 'kuala lumpur', 'singapore', 'manila']
# one line with list comprehension
cities_capitalized_lc = [city.title() for city in cities]
print(cities_capitalized_lc)
['Jakarta', 'Kuala Lumpur', 'Singapore', 'Manila']
cities_capitalized == cities_capitalized_lc # use the comparison operator to assert equality
# Another example
# Task: to square a list of numbers
numbers = [1, 2, 3, 4]
numbers_squared = [number**2 for number in numbers]
print(numbers_squared)
[1, 4, 9, 16]
# Another example
# Task: to square a list of numbers
numbers = [1, 2, 3, 4]
numbers_squared = [whatever * whatever for whatever in numbers]
print(numbers_squared)
[1, 4, 9, 16]
# Another example
# Task: to square a list of numbers
numbers = [1, 2, 3, 4]
numbers_squared = [number * number for number in numbers]
print(numbers_squared)
[1, 4, 9, 16]
numbers = list(range(10))
print(numbers)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers_even = []
for number in numbers:
if number % 2 == 0:
numbers_even.append(number)
print(numbers_even)
[0, 2, 4, 6, 8]
# you can also add conditional in a list comprehension
numbers = list(range(10))
# get all the even numbers using list comprehension
numbers_even = [number for number in numbers if number % 2 == 0]
print(numbers_even)
[0, 2, 4, 6, 8]
# now get the odd number
# you can also add conditional in a list comprehension
numbers = list(range(10))
# get all the odd numbers using list comprehension
numbers_odd = [number for number in numbers if number % 2 != 0]
print(numbers_odd)
[1, 3, 5, 7, 9]
# you can also add conditional in a list comprehension
numbers = list(range(10))
# get all the even numbers using list comprehension
numbers_even = [number for number in numbers if number % 2 == 0 else "replaced"]
print(numbers_even)
SyntaxError: invalid syntax (<ipython-input-22-6bd0fae335ea>, line 5)
# if you want to add an else clause, it must be placed before the for loop
# let's say you want to set all even numbers to zero but retain the odd numbers
numbers = list(range(10))
numbers_modified = [number if number % 2 != 0 else "replaced" for number in numbers]
print(numbers_modified)
['replaced', 1, 'replaced', 3, 'replaced', 5, 'replaced', 7, 'replaced', 9]
numbers = list(range(10))
numbers_modified = [number if number % 2 != 0 for number in numbers]
print(numbers_modified)
SyntaxError: invalid syntax (<ipython-input-25-661e46740fd4>, line 2)
# conditional expression
"Yes" if numbers[0] == 0 else "No"
# the if statement here is part of the syntax of list comprehension
[number for number in numbers if number % 2 != 0]
# Exercise 1
# Ivy Felicia
names = ["Antonio Ruiz", "Luiz Suarez", "Lionel Messi", "Philippe Coutinho", "Sergio Ramos"]
# TODO: create a new list first_names containing just the first names in names
# Do not forget to make it lowercase
# Use a list comprehension
first_names = [ name.split()[0].lower() for name in names]
print(first_names)
['antonio', 'luiz', 'lionel', 'philippe', 'sergio']
name = names[0]
print(name)
name.split() # this returns a list containing elements of the original string separated by whitespace
Antonio Ruiz
name.split()[0]
%run -i students.py
Unsupported output type: clearOutput
The chosen one is: Ivy Felicia
# Exercise 2
# Gavin
# TODO: create the first 20 multiples of 4
# HINT: the first three multiples of 4 are 4, 8, 12.
multiples_4 = None
multiples_4 = [4*x for x in range(1, 21)]
print(multiples_4)
[4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80]
%run -i students.py
Unsupported output type: clearOutput
The chosen one is: Wesley Jonathan
# Exercise 3: count fruits in your basket
basket_items = {'bananas': 8, 'grapes': 20, 'milk': 3, 'cheese': 8}
fruits = ['apples', 'oranges', 'pears', 'peaches', 'grapes', 'bananas']
result = 0
# Iterate through the dictionary
for item in basket_items:
# if the key is in the list of fruits, add the value (number of fruits) to result
if item in fruits:
result += basket_items[item]
print(result)
28
for fruit, count in basket_items.items():
print(fruit, count)
bananas 8
grapes 20
milk 3
cheese 8
for fruit in basket_items:
print(fruit, basket_items[fruit])
bananas 8
grapes 20
milk 3
cheese 8
sum([count for fruit, count in basket_items.items() if fruit in fruits])
# Exercise 3: count fruits in your basket
# Wesley Jonathan
basket_items = {'bananas': 8, 'grapes': 20, 'milk': 3, 'cheese': 8}
fruits = ['apples', 'oranges', 'pears', 'peaches', 'grapes', 'bananas']
# TODO: use a list comprehension to count the number of fruits in your basket
number_fruits = None
number_fruits = sum([count for fruit, count in basket_items.items() if fruit in fruits])
print(number_fruits)
28
number = 6 # the number whose factorial we want to calculate
result = 1
while number > 1:
result *= number
number -= 1
print(result)
720
number = 6
result = 1
for n in range(1, number + 1):
result *= n
print(result)
720
import sys
sys.version
%run -i students.py
Unsupported output type: clearOutput
The chosen one is: Natalia Chan
# Exercise 5
scores = {
"Antonio Ruiz": 70,
"Luiz Suarez": 35,
"Lionel Messi": 82,
"Philippe Coutinho": 23,
"Sergio Ramos": 98
}
# TODO: create a list of names, called passed, that contains the names of students who score at least 65
passed = [player for player,score in scores.items() if score >= 65]
print(passed)
['Antonio Ruiz', 'Lionel Messi', 'Sergio Ramos']
# Challenge 1: report how many times each director won the Oscar, and also how many times a director is nominated for Oscar.
# you are provided with the data of Oscar Award Nominations for the Best Director between 1931 and 2010.
# data 1: a dictionary that contains list of directors nominated for each year
nominated = {1931: ['Norman Taurog', 'Wesley Ruggles', 'Clarence Brown', 'Lewis Milestone', 'Josef Von Sternberg'], 1932: ['Frank Borzage', 'King Vidor', 'Josef Von Sternberg'], 1933: ['Frank Lloyd', 'Frank Capra', 'George Cukor'], 1934: ['Frank Capra', 'Victor Schertzinger', 'W. S. Van Dyke'], 1935: ['John Ford', 'Michael Curtiz', 'Henry Hathaway', 'Frank Lloyd'], 1936: ['Frank Capra', 'William Wyler', 'Robert Z. Leonard', 'Gregory La Cava', 'W. S. Van Dyke'], 1937: ['Leo McCarey', 'Sidney Franklin', 'William Dieterle', 'Gregory La Cava', 'William Wellman'], 1938: ['Frank Capra', 'Michael Curtiz', 'Norman Taurog', 'King Vidor', 'Michael Curtiz'], 1939: ['Sam Wood', 'Frank Capra', 'John Ford', 'William Wyler', 'Victor Fleming'], 1940: ['John Ford', 'Sam Wood', 'William Wyler', 'George Cukor', 'Alfred Hitchcock'], 1941: ['John Ford', 'Orson Welles', 'Alexander Hall', 'William Wyler', 'Howard Hawks'], 1942: ['Sam Wood', 'Mervyn LeRoy', 'John Farrow', 'Michael Curtiz', 'William Wyler'], 1943: ['Michael Curtiz', 'Ernst Lubitsch', 'Clarence Brown', 'George Stevens', 'Henry King'], 1944: ['Leo McCarey', 'Billy Wilder', 'Otto Preminger', 'Alfred Hitchcock', 'Henry King'], 1945: ['Billy Wilder', 'Leo McCarey', 'Clarence Brown', 'Jean Renoir', 'Alfred Hitchcock'], 1946: ['David Lean', 'Frank Capra', 'Robert Siodmak', 'Clarence Brown', 'William Wyler'], 1947: ['Elia Kazan', 'Henry Koster', 'Edward Dmytryk', 'George Cukor', 'David Lean'], 1948: ['John Huston', 'Laurence Olivier', 'Jean Negulesco', 'Fred Zinnemann', 'Anatole Litvak'], 1949: ['Joseph L. Mankiewicz', 'Robert Rossen', 'William A. Wellman', 'Carol Reed', 'William Wyler'], 1950: ['Joseph L. Mankiewicz', 'John Huston', 'George Cukor', 'Billy Wilder', 'Carol Reed'], 1951: ['George Stevens', 'John Huston', 'Vincente Minnelli', 'William Wyler', 'Elia Kazan'], 1952: ['John Ford', 'Joseph L. Mankiewicz', 'Cecil B. DeMille', 'Fred Zinnemann', 'John Huston'], 1953: ['Fred Zinnemann', 'Charles Walters', 'William Wyler', 'George Stevens', 'Billy Wilder'], 1954: ['Elia Kazan', 'George Seaton', 'William Wellman', 'Alfred Hitchcock', 'Billy Wilder'], 1955: ['Delbert Mann', 'John Sturges', 'Elia Kazan', 'Joshua Logan', 'David Lean'], 1956: ['George Stevens', 'Michael Anderson', 'William Wyler', 'Walter Lang', 'King Vidor'], 1957: ['David Lean', 'Mark Robson', 'Joshua Logan', 'Sidney Lumet', 'Billy Wilder'], 1958: ['Richard Brooks', 'Stanley Kramer', 'Robert Wise', 'Mark Robson', 'Vincente Minnelli'], 1959: ['George Stevens', 'Fred Zinnemann', 'Jack Clayton', 'Billy Wilder', 'William Wyler'], 1960: ['Billy Wilder', 'Jules Dassin', 'Alfred Hitchcock', 'Jack Cardiff', 'Fred Zinnemann'], 1961: ['J. Lee Thompson', 'Robert Rossen', 'Stanley Kramer', 'Federico Fellini', 'Robert Wise', 'Jerome Robbins'], 1962: ['David Lean', 'Frank Perry', 'Pietro Germi', 'Arthur Penn', 'Robert Mulligan'], 1963: ['Elia Kazan', 'Otto Preminger', 'Federico Fellini', 'Martin Ritt', 'Tony Richardson'], 1964: ['George Cukor', 'Peter Glenville', 'Stanley Kubrick', 'Robert Stevenson', 'Michael Cacoyannis'], 1965: ['William Wyler', 'John Schlesinger', 'David Lean', 'Hiroshi Teshigahara', 'Robert Wise'], 1966: ['Fred Zinnemann', 'Michelangelo Antonioni', 'Claude Lelouch', 'Richard Brooks', 'Mike Nichols'], 1967: ['Arthur Penn', 'Stanley Kramer', 'Richard Brooks', 'Norman Jewison', 'Mike Nichols'], 1968: ['Carol Reed', 'Gillo Pontecorvo', 'Anthony Harvey', 'Franco Zeffirelli', 'Stanley Kubrick'], 1969: ['John Schlesinger', 'Arthur Penn', 'George Roy Hill', 'Sydney Pollack', 'Costa-Gavras'], 1970: ['Franklin J. Schaffner', 'Federico Fellini', 'Arthur Hiller', 'Robert Altman', 'Ken Russell'], 1971: ['Stanley Kubrick', 'Norman Jewison', 'Peter Bogdanovich', 'John Schlesinger', 'William Friedkin'], 1972: ['Bob Fosse', 'John Boorman', 'Jan Troell', 'Francis Ford Coppola', 'Joseph L. Mankiewicz'], 1973: ['George Roy Hill', 'George Lucas', 'Ingmar Bergman', 'William Friedkin', 'Bernardo Bertolucci'], 1974: ['Francis Ford Coppola', 'Roman Polanski', 'Francois Truffaut', 'Bob Fosse', 'John Cassavetes'], 1975: ['Federico Fellini', 'Stanley Kubrick', 'Sidney Lumet', 'Robert Altman', 'Milos Forman'], 1976: ['Alan J. Pakula', 'Ingmar Bergman', 'Sidney Lumet', 'Lina Wertmuller', 'John G. Avildsen'], 1977: ['Steven Spielberg', 'Fred Zinnemann', 'George Lucas', 'Herbert Ross', 'Woody Allen'], 1978: ['Hal Ashby', 'Warren Beatty', 'Buck Henry', 'Woody Allen', 'Alan Parker', 'Michael Cimino'], 1979: ['Bob Fosse', 'Francis Coppola', 'Peter Yates', 'Edouard Molinaro', 'Robert Benton'], 1980: ['David Lynch', 'Martin Scorsese', 'Richard Rush', 'Roman Polanski', 'Robert Redford'], 1981: ['Louis Malle', 'Hugh Hudson', 'Mark Rydell', 'Steven Spielberg', 'Warren Beatty'], 1982: ['Wolfgang Petersen', 'Steven Spielberg', 'Sydney Pollack', 'Sidney Lumet', 'Richard Attenborough'], 1983: ['Peter Yates', 'Ingmar Bergman', 'Mike Nichols', 'Bruce Beresford', 'James L. Brooks'], 1984: ['Woody Allen', 'Roland Joffe', 'David Lean', 'Robert Benton', 'Milos Forman'], 1985: ['Hector Babenco', 'John Huston', 'Akira Kurosawa', 'Peter Weir', 'Sydney Pollack'], 1986: ['David Lynch', 'Woody Allen', 'Roland Joffe', 'James Ivory', 'Oliver Stone'], 1987: ['Bernardo Bertolucci', 'Adrian Lyne', 'John Boorman', 'Norman Jewison', 'Lasse Hallstrom'], 1988: ['Barry Levinson', 'Charles Crichton', 'Martin Scorsese', 'Alan Parker', 'Mike Nichols'], 1989: ['Woody Allen', 'Peter Weir', 'Kenneth Branagh', 'Jim Sheridan', 'Oliver Stone'], 1990: ['Francis Ford Coppola', 'Martin Scorsese', 'Stephen Frears', 'Barbet Schroeder', 'Kevin Costner'], 1991: ['John Singleton', 'Barry Levinson', 'Oliver Stone', 'Ridley Scott', 'Jonathan Demme'], 1992: ['Clint Eastwood', 'Neil Jordan', 'James Ivory', 'Robert Altman', 'Martin Brest'], 1993: ['Jim Sheridan', 'Jane Campion', 'James Ivory', 'Robert Altman', 'Steven Spielberg'], 1994: ['Woody Allen', 'Quentin Tarantino', 'Robert Redford', 'Krzysztof Kieslowski', 'Robert Zemeckis'], 1995: ['Chris Noonan', 'Tim Robbins', 'Mike Figgis', 'Michael Radford', 'Mel Gibson'], 1996: ['Anthony Minghella', 'Joel Coen', 'Milos Forman', 'Mike Leigh', 'Scott Hicks'], 1997: ['Peter Cattaneo', 'Gus Van Sant', 'Curtis Hanson', 'Atom Egoyan', 'James Cameron'], 1998: ['Roberto Benigni', 'John Madden', 'Terrence Malick', 'Peter Weir', 'Steven Spielberg'], 1999: ['Spike Jonze', 'Lasse Hallstrom', 'Michael Mann', 'M. Night Shyamalan', 'Sam Mendes'], 2000: ['Stephen Daldry', 'Ang Lee', 'Steven Soderbergh', 'Ridley Scott', 'Steven Soderbergh'], 2001: ['Ridley Scott', 'Robert Altman', 'Peter Jackson', 'David Lynch', 'Ron Howard'], 2002: ['Rob Marshall', 'Martin Scorsese', 'Stephen Daldry', 'Pedro Almodovar', 'Roman Polanski'], 2003: ['Fernando Meirelles', 'Sofia Coppola', 'Peter Weir', 'Clint Eastwood', 'Peter Jackson'], 2004: ['Martin Scorsese', 'Taylor Hackford', 'Alexander Payne', 'Mike Leigh', 'Clint Eastwood'], 2005: ['Ang Lee', 'Bennett Miller', 'Paul Haggis', 'George Clooney', 'Steven Spielberg'], 2006: ['Alejandro Gonzaalez Inarritu', 'Clint Eastwood', 'Stephen Frears', 'Paul Greengrass', 'Martin Scorsese'], 2007: ['Julian Schnabel', 'Jason Reitman', 'Tony Gilroy', 'Paul Thomas Anderson', 'Joel Coen', 'Ethan Coen'], 2008: ['David Fincher', 'Ron Howard', 'Gus Van Sant', 'Stephen Daldry', 'Danny Boyle'], 2009: ['James Cameron', 'Quentin Tarantino', 'Lee Daniels', 'Jason Reitman', 'Kathryn Bigelow'], 2010: ['Darren Aronofsky', 'David O. Russell', 'David Fincher', 'Ethan Coen', 'Joel Coen', 'Tom Hooper']}
# data 2: a dictionary that contains list of directors who won the Oscar for each year
winners = {1931: ['Norman Taurog'], 1932: ['Frank Borzage'], 1933: ['Frank Lloyd'], 1934: ['Frank Capra'], 1935: ['John Ford'], 1936: ['Frank Capra'], 1937: ['Leo McCarey'], 1938: ['Frank Capra'], 1939: ['Victor Fleming'], 1940: ['John Ford'], 1941: ['John Ford'], 1942: ['William Wyler'], 1943: ['Michael Curtiz'], 1944: ['Leo McCarey'], 1945: ['Billy Wilder'], 1946: ['William Wyler'], 1947: ['Elia Kazan'], 1948: ['John Huston'], 1949: ['Joseph L. Mankiewicz'], 1950: ['Joseph L. Mankiewicz'], 1951: ['George Stevens'], 1952: ['John Ford'], 1953: ['Fred Zinnemann'], 1954: ['Elia Kazan'], 1955: ['Delbert Mann'], 1956: ['George Stevens'], 1957: ['David Lean'], 1958: ['Vincente Minnelli'], 1959: ['William Wyler'], 1960: ['Billy Wilder'], 1961: ['Jerome Robbins', 'Robert Wise'], 1962: ['David Lean'], 1963: ['Tony Richardson'], 1964: ['George Cukor'], 1965: ['Robert Wise'], 1966: ['Fred Zinnemann'], 1967: ['Mike Nichols'], 1968: ['Carol Reed'], 1969: ['John Schlesinger'], 1970: ['Franklin J. Schaffner'], 1971: ['William Friedkin'], 1972: ['Bob Fosse'], 1973: ['George Roy Hill'], 1974: ['Francis Ford Coppola'], 1975: ['Milos Forman'], 1976: ['John G. Avildsen'], 1977: ['Woody Allen'], 1978: ['Michael Cimino'], 1979: ['Robert Benton'], 1980: ['Robert Redford'], 1981: ['Warren Beatty'], 1982: ['Richard Attenborough'], 1983: ['James L. Brooks'], 1984: ['Milos Forman'], 1985: ['Sydney Pollack'], 1986: ['Oliver Stone'], 1987: ['Bernardo Bertolucci'], 1988: ['Barry Levinson'], 1989: ['Oliver Stone'], 1990: ['Kevin Costner'], 1991: ['Jonathan Demme'], 1992: ['Clint Eastwood'], 1993: ['Steven Spielberg'], 1994: ['Robert Zemeckis'], 1995: ['Mel Gibson'], 1996: ['Anthony Minghella'], 1997: ['James Cameron'], 1998: ['Steven Spielberg'], 1999: ['Sam Mendes'], 2000: ['Steven Soderbergh'], 2001: ['Ron Howard'], 2002: ['Roman Polanski'], 2003: ['Peter Jackson'], 2004: ['Clint Eastwood'], 2005: ['Ang Lee'], 2006: ['Martin Scorsese'], 2007: ['Ethan Coen', 'Joel Coen'], 2008: ['Danny Boyle'], 2009: ['Kathryn Bigelow'], 2010: ['Tom Hooper']}
# Task 1: create a dictionary that counts how many times each director is nominated for the Oscar
# Hint: you need to use two `for` loops
nom_count_dict = {}
for _, directors in nominated.items():
for director in directors:
nom_count_dict[director] = nom_count_dict.get(director, 0) + 1
print("nom_count_dict = {}\n".format(nom_count_dict))
# Task 2: create a dictionary that counts how many times each director won the Oscar
win_count_dict = {}
for _, directors in winners.items():
for director in directors:
win_count_dict[director] = win_count_dict.get(director, 0) + 1
print("win_count_dict = {}".format(win_count_dict))
# Task 3: find which director won the oscar the most number of times
names, times = zip(*win_count_dict.items()) # or you can simply use max(win_count_dict.values())
most_wins = [name for name in win_count_dict if win_count_dict[name] == max(times)]
print(most_wins)
nom_count_dict = {'Norman Taurog': 2, 'Wesley Ruggles': 1, 'Clarence Brown': 4, 'Lewis Milestone': 1, 'Josef Von Sternberg': 2, 'Frank Borzage': 1, 'King Vidor': 3, 'Frank Lloyd': 2, 'Frank Capra': 6, 'George Cukor': 5, 'Victor Schertzinger': 1, 'W. S. Van Dyke': 2, 'John Ford': 5, 'Michael Curtiz': 5, 'Henry Hathaway': 1, 'William Wyler': 12, 'Robert Z. Leonard': 1, 'Gregory La Cava': 2, 'Leo McCarey': 3, 'Sidney Franklin': 1, 'William Dieterle': 1, 'William Wellman': 2, 'Sam Wood': 3, 'Victor Fleming': 1, 'Alfred Hitchcock': 5, 'Orson Welles': 1, 'Alexander Hall': 1, 'Howard Hawks': 1, 'Mervyn LeRoy': 1, 'John Farrow': 1, 'Ernst Lubitsch': 1, 'George Stevens': 5, 'Henry King': 2, 'Billy Wilder': 8, 'Otto Preminger': 2, 'Jean Renoir': 1, 'David Lean': 7, 'Robert Siodmak': 1, 'Elia Kazan': 5, 'Henry Koster': 1, 'Edward Dmytryk': 1, 'John Huston': 5, 'Laurence Olivier': 1, 'Jean Negulesco': 1, 'Fred Zinnemann': 7, 'Anatole Litvak': 1, 'Joseph L. Mankiewicz': 4, 'Robert Rossen': 2, 'William A. Wellman': 1, 'Carol Reed': 3, 'Vincente Minnelli': 2, 'Cecil B. DeMille': 1, 'Charles Walters': 1, 'George Seaton': 1, 'Delbert Mann': 1, 'John Sturges': 1, 'Joshua Logan': 2, 'Michael Anderson': 1, 'Walter Lang': 1, 'Mark Robson': 2, 'Sidney Lumet': 4, 'Richard Brooks': 3, 'Stanley Kramer': 3, 'Robert Wise': 3, 'Jack Clayton': 1, 'Jules Dassin': 1, 'Jack Cardiff': 1, 'J. Lee Thompson': 1, 'Federico Fellini': 4, 'Jerome Robbins': 1, 'Frank Perry': 1, 'Pietro Germi': 1, 'Arthur Penn': 3, 'Robert Mulligan': 1, 'Martin Ritt': 1, 'Tony Richardson': 1, 'Peter Glenville': 1, 'Stanley Kubrick': 4, 'Robert Stevenson': 1, 'Michael Cacoyannis': 1, 'John Schlesinger': 3, 'Hiroshi Teshigahara': 1, 'Michelangelo Antonioni': 1, 'Claude Lelouch': 1, 'Mike Nichols': 4, 'Norman Jewison': 3, 'Gillo Pontecorvo': 1, 'Anthony Harvey': 1, 'Franco Zeffirelli': 1, 'George Roy Hill': 2, 'Sydney Pollack': 3, 'Costa-Gavras': 1, 'Franklin J. Schaffner': 1, 'Arthur Hiller': 1, 'Robert Altman': 5, 'Ken Russell': 1, 'Peter Bogdanovich': 1, 'William Friedkin': 2, 'Bob Fosse': 3, 'John Boorman': 2, 'Jan Troell': 1, 'Francis Ford Coppola': 3, 'George Lucas': 2, 'Ingmar Bergman': 3, 'Bernardo Bertolucci': 2, 'Roman Polanski': 3, 'Francois Truffaut': 1, 'John Cassavetes': 1, 'Milos Forman': 3, 'Alan J. Pakula': 1, 'Lina Wertmuller': 1, 'John G. Avildsen': 1, 'Steven Spielberg': 6, 'Herbert Ross': 1, 'Woody Allen': 6, 'Hal Ashby': 1, 'Warren Beatty': 2, 'Buck Henry': 1, 'Alan Parker': 2, 'Michael Cimino': 1, 'Francis Coppola': 1, 'Peter Yates': 2, 'Edouard Molinaro': 1, 'Robert Benton': 2, 'David Lynch': 3, 'Martin Scorsese': 6, 'Richard Rush': 1, 'Robert Redford': 2, 'Louis Malle': 1, 'Hugh Hudson': 1, 'Mark Rydell': 1, 'Wolfgang Petersen': 1, 'Richard Attenborough': 1, 'Bruce Beresford': 1, 'James L. Brooks': 1, 'Roland Joffe': 2, 'Hector Babenco': 1, 'Akira Kurosawa': 1, 'Peter Weir': 4, 'James Ivory': 3, 'Oliver Stone': 3, 'Adrian Lyne': 1, 'Lasse Hallstrom': 2, 'Barry Levinson': 2, 'Charles Crichton': 1, 'Kenneth Branagh': 1, 'Jim Sheridan': 2, 'Stephen Frears': 2, 'Barbet Schroeder': 1, 'Kevin Costner': 1, 'John Singleton': 1, 'Ridley Scott': 3, 'Jonathan Demme': 1, 'Clint Eastwood': 4, 'Neil Jordan': 1, 'Martin Brest': 1, 'Jane Campion': 1, 'Quentin Tarantino': 2, 'Krzysztof Kieslowski': 1, 'Robert Zemeckis': 1, 'Chris Noonan': 1, 'Tim Robbins': 1, 'Mike Figgis': 1, 'Michael Radford': 1, 'Mel Gibson': 1, 'Anthony Minghella': 1, 'Joel Coen': 3, 'Mike Leigh': 2, 'Scott Hicks': 1, 'Peter Cattaneo': 1, 'Gus Van Sant': 2, 'Curtis Hanson': 1, 'Atom Egoyan': 1, 'James Cameron': 2, 'Roberto Benigni': 1, 'John Madden': 1, 'Terrence Malick': 1, 'Spike Jonze': 1, 'Michael Mann': 1, 'M. Night Shyamalan': 1, 'Sam Mendes': 1, 'Stephen Daldry': 3, 'Ang Lee': 2, 'Steven Soderbergh': 2, 'Peter Jackson': 2, 'Ron Howard': 2, 'Rob Marshall': 1, 'Pedro Almodovar': 1, 'Fernando Meirelles': 1, 'Sofia Coppola': 1, 'Taylor Hackford': 1, 'Alexander Payne': 1, 'Bennett Miller': 1, 'Paul Haggis': 1, 'George Clooney': 1, 'Alejandro Gonzaalez Inarritu': 1, 'Paul Greengrass': 1, 'Julian Schnabel': 1, 'Jason Reitman': 2, 'Tony Gilroy': 1, 'Paul Thomas Anderson': 1, 'Ethan Coen': 2, 'David Fincher': 2, 'Danny Boyle': 1, 'Lee Daniels': 1, 'Kathryn Bigelow': 1, 'Darren Aronofsky': 1, 'David O. Russell': 1, 'Tom Hooper': 1}
win_count_dict = {'Norman Taurog': 1, 'Frank Borzage': 1, 'Frank Lloyd': 1, 'Frank Capra': 3, 'John Ford': 4, 'Leo McCarey': 2, 'Victor Fleming': 1, 'William Wyler': 3, 'Michael Curtiz': 1, 'Billy Wilder': 2, 'Elia Kazan': 2, 'John Huston': 1, 'Joseph L. Mankiewicz': 2, 'George Stevens': 2, 'Fred Zinnemann': 2, 'Delbert Mann': 1, 'David Lean': 2, 'Vincente Minnelli': 1, 'Jerome Robbins': 1, 'Robert Wise': 2, 'Tony Richardson': 1, 'George Cukor': 1, 'Mike Nichols': 1, 'Carol Reed': 1, 'John Schlesinger': 1, 'Franklin J. Schaffner': 1, 'William Friedkin': 1, 'Bob Fosse': 1, 'George Roy Hill': 1, 'Francis Ford Coppola': 1, 'Milos Forman': 2, 'John G. Avildsen': 1, 'Woody Allen': 1, 'Michael Cimino': 1, 'Robert Benton': 1, 'Robert Redford': 1, 'Warren Beatty': 1, 'Richard Attenborough': 1, 'James L. Brooks': 1, 'Sydney Pollack': 1, 'Oliver Stone': 2, 'Bernardo Bertolucci': 1, 'Barry Levinson': 1, 'Kevin Costner': 1, 'Jonathan Demme': 1, 'Clint Eastwood': 2, 'Steven Spielberg': 2, 'Robert Zemeckis': 1, 'Mel Gibson': 1, 'Anthony Minghella': 1, 'James Cameron': 1, 'Sam Mendes': 1, 'Steven Soderbergh': 1, 'Ron Howard': 1, 'Roman Polanski': 1, 'Peter Jackson': 1, 'Ang Lee': 1, 'Martin Scorsese': 1, 'Ethan Coen': 1, 'Joel Coen': 1, 'Danny Boyle': 1, 'Kathryn Bigelow': 1, 'Tom Hooper': 1}
['John Ford']