[Solved] how to print all phone numbers in file [closed]


To print a file line by line you can just use a 2 line for loop

file = open("name_of_file.txt", "r")

for line in file:
    print(line)

You can then save that line to a variable to use later in the loop –

file = open("name_of_file.txt", "r")

for line in file:
    phonenb = line

Alternatively you could make each line an element in a list –

file = "name_of_file.txt"
lines = [line.split() for line in open(file)]
print(lines)

3

solved how to print all phone numbers in file [closed]