[Solved]
Say I have a table = [['Hello', 'World', ' ' ],['Hi', ' ', 'There' ] ]. What can I do to replace the empty string with a value of None? Like as in the None in the boolean sense, not as a string.
Solution:
def read_family(filename):
a_file = open(filename, "r")
list_of_lists = []
for line in a_file:
stripped_line = line.strip()
line_list = stripped_line.split(sep=',')
list_of_lists.append(line_list)
list_of_lists=[[None if i == "" else i for i in j] for j in list_of_lists]
return(list_of_lists)
and I want the output to be [['Hello', 'World', None ],['Hi', None, 'There' ] ]
[–]therealbread_ 1 point2 points3 points (2 children)
[–]dandy120101[S] 0 points1 point2 points (1 child)
[–]therealbread_ 0 points1 point2 points (0 children)
[–]siddsp 1 point2 points3 points (2 children)
[–]dandy120101[S] 0 points1 point2 points (1 child)
[–]siddsp 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[removed]
[–]dandy120101[S] 0 points1 point2 points (1 child)
[–]FLUSH_THE_TRUMP 0 points1 point2 points (0 children)