I essentially want to do an Index-Match(think Excel) type formula in Python to replace the None in tuple_list with an the equivalent value in tuple_list1.
My code:
tuple_list = [("pineapple", 5), ("cherry", 7), ("kumquat", None), ("plum", None)]
tuple_list1 = [("orange, 10"),("plum", 10),("kumquat", 23)]
for item in tuple_list:
if item[1] == None:
item[1] = tuple_list[tuple_list1.index(item[0])][1]
print tuple_list
My error:
ValueError: 'kumquat' is not in list
Desired Output:
[("pineapple", 5), ("cherry", 7), ("kumquat", 23), ("plum", 10)]
("orange", 10)instead of("orange, 10").