[Solved] How to print word that you want inside a textfile?
Use readlines and output the lines according to their index. with open(‘addon/entertainment.txt’) as f: lines = f.readlines() for line in lines: print(“{}. {}”.format(lines.index(line) + 1, line)) desired_lines = [3, 5] output = [] for desired in desired_lines: output.append(lines[desired – 1]) for o in output: print(“{}. {}”.format(output.index(o) + 1, o)) Alternatively, if you want to select … Read more