TypeError: list indices must be integers, not list. How to fix?
问题 There's the code with the TypeError in it. "list indices must be integers, not list", though they are integers. I'd appreciate you helping me figure out what's wrong. What I need is to get matrix 7x5 from source 7x5 tab with different values. The error occurs on the last line. lines = [] with open("text.txt") as f: for line in f: line = [int(x) for x in line if (x != ' ') and (x != '\n')] lines.append(line) f.close() What I have after reading file is list of lists with numbers called "lines".