Jose Miguel Morales
Jose Miguel Morales

Reputation: 1

How to read line by line out of a file

input file:

1
2
3
4
5

what I have at this time:

filename=input("Please enter the filename or path: ")
with open(filename, 'r') as file:
    filecontents=tuple(map(int, file.read().split()))

print(filecontents)

output: (1,2,3,4,5)

intended output:

1
2
3
4
5

Upvotes: 0

Views: 31

Answers (0)

Related Questions