Answer:
file1=[ ]
file2=[ ]
file3=[ ]
f1=open('data1.txt','r')
for line in f1:
line=line.strip().split(', ')
file1.append((line[0],line[1]))
f1.close()
f2=open('data2.txt','r')
for line in f2:
line=line.strip().split(', ')
file2.append((line[0],line[1]))
f2.close()
f3=open('data3.txt','r')
for line in f3:
line=line.strip().split(', ')
file3.append((line[0],line[1]))
f3.close()
l=[ ]
for x in file2:
for y in file3:
if x[1] in y:
l.append((x[0],y))
final_file=[]
for x in file1:
for y in l:
if x[0] in y:
final_file.append((x[1],y[0],*y[1]))
#This is where the program will ask the user for their telephone number
tel_num=input('Enter the telephone number: ')
temp=0
for data in final_file:
if data[0]==tel_num:
temp=1
print('Telephone number: ',tel_num)
print('Name: ',data[1])
print('Social Security number: ',data[2])
print('Annual income: ',data[3])
if temp==0:
print('No data available for this telephone number.')