Skip to content
Snippets Groups Projects
Commit e4e16573 authored by cprutean's avatar cprutean
Browse files

Upload New File

parent 737ed5ad
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:3747cf6a tags:
# Read Text File
%% Cell type:code id:d510374a tags:
``` python
"""
Read a text file and print out to terminal
"""
def main():
filename = str(input("Input file name : "))
filein = open(filename, "r") # Open file for reading
input_data = filein.readlines() # Read in data as list of strings
for line in input_data: # Scan through writing lines
print(line) # Note extra "\n" problem
for line in input_data:
print (line[:-1]) # This removes the last character
main()
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment