<jupyter_start><jupyter_text>All the IPython Notebooks in this **Python Examples** series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/90_Python_Examples)**  Python Program to Read a File Line by Line Into a ListIn this example, you will learn to read a file line by line into a list.To understand this example, you should have the knowledge of the following **[Python programming](https://github.com/milaan9/01_Python_Introduction/blob/main/000_Intro_to_Python.ipynb)** topics:* **[Python File I/O](https://github.com/milaan9/05_Python_Files/blob/main/001_Python_File_Input_Output.ipynb)** Let the content of the file **`vaccine_data.txt`** be:```Small-Pox Edward-Jenner England-1796Cholera Louis-Pasteur France-1880Polio Jones-Salk US-1952```>**Note:** **`vaccine_data.csv`** file contains the complete list.  Using shutil module<jupyter_code># Example 1: 

#with open("vaccine_data.csv") as f:
with open("vaccine_data.txt") as f:
    content_list = f.readlines()

# print the list
print(content_list, "\n")

# remove new line characters
content_list = [x.strip() for x in content_list]
print(content_list)<jupyter_output>['Small-Pox Edward-Jenner England-1796\n', 'Cholera Louis-Pasteur France-1880\n', 'Polio Jones-Salk US-1952\n', '\n'] 

['Small-Pox Edward-Jenner England-1796', 'Cholera Louis-Pasteur France-1880', 'Polio Jones-Salk US-1952', '']<jupyter_text>**Explanation:****`readlines()`** returns a list of lines from the file.First, open the file and read the file using **`readlines()`**.If you want to remove the new lines **`\n`**, you can use **`strip()`**.<jupyter_code># Example 2: Using for loop and list comprehension

#with open("vaccine_data.csv") as f:
with open("vaccine_data.txt") as f:
    content_list = [line for line in f]

print(content_list, "\n")

# removing the characters
#with open("vaccine_data.csv") as f:
with open("vaccine_data.txt") as f:
    content_list = [line.rstrip() for line in f]

print(content_list)<jupyter_output>['Small-Pox Edward-Jenner England-1796\n', 'Cholera Louis-Pasteur France-1880\n', 'Polio Jones-Salk US-1952\n', '\n'] 

['Small-P<NAME>-Jenner England-1796', 'Cholera Louis-Pasteur France-1880', 'Polio Jones-Salk US-1952', '']
{'fraction_non_alphanumeric': 0.14679313459801266, 'fraction_numerical': 0.03477868112014453, 'mean_word_length': 5.533923303834809, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '52477', 'license': 'MIT', 'n_tokens_mistral': 841, 'n_tokens_neox': 756, 'n_words': 217, 'path': '05_Python_Files_examples/007_read_a_file_line_by_line_into_a_list/007_read_a_file_line_by_line_into_a_list.ipynb', 'repo_name': 'peterennis/90_Python_Examples', 'size': '2224'}