0
How to print every other line from a file?
I need to read from a file and print every other line but I have been unsuccessful. Any help would be appreciated!! thanks
3 Réponses
+ 8
with open("filename.txt") as file:
lines = file.readlines()
for i in range(len(lines)):
if not i % 2:
print(lines[i])
Edit - here is an example https://code.sololearn.com/c9zfyKcPJ3uj/#py
+ 2
Link your code and we should be able to tell you the answer.
+ 1
Please consider more suitable keywords next time