Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. wonder_woman = ['Wonder Woman','Patty Jenkins','Color',141,'Gal Gadot','English','USA',2017]
  2.  
  3. def is_usa(input_lst):
  4.     if input_lst[6] == "USA":
  5.         return True
  6.     else:
  7.         return False
  8.    
  9. def index_equals_str(input_lst, index, input_str):
  10.     if input_lst[index] == input_str:
  11.         return True
  12.     else:
  13.         return False
  14.  
  15. wonder_woman_in_color = index_equals_str(input_str="Color", index=2, input_lst=wonder_woman)
  16.  
  17. # End of dataquest challenge
  18.  
  19. # My own try to use the function in a loop and add the results to a list
  20.  
  21. f = open("movie_metadata.csv", "r")
  22. data = f.read()
  23. rows = data.split("\n")
  24. aufbereitet = []
  25.  
  26. for row in rows:
  27.     einmalig = row.split(",")
  28.     aufbereitet.append(einmalig)
  29. # print(aufbereitet)
  30.  
  31. finale_liste = []
  32.  
  33. for item in aufbereitet:
  34.     test = index_equals_str(input_str="Color", index=2, input_lst=aufbereitet)
  35.     finale_liste.append(test)
  36.  
  37. print(finale_liste)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement