Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python Using for loop and list comprehension

with open('data_file.txt') as f:
    content_list = [line for line in f]

print(content_list)

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

print(content_list)
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #python #Using #loop #list #comprehension
ADD COMMENT
Topic
Name
4+1 =