# Function to read files line by line def ReadFile(filename): with open(filename, "r+") as file: lines = file.readlines() return lines # Driver Program - Make sure you keep the txt file in the same directory where .py file is filename = "test.txt" lines = ReadFile(filename) for i in lines: print(i.rstrip())
Clear Doubts with Computer TutorIn case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in
You cannot copy content of this page