Write a program that queries information from three files. Program should ask for user input telephone number, print name, ss number, annual income

The first file contains the names and telephone numbers of a group of people. The second file contains the names and Social Security numbers of a group of people. The third file contains the Social Security numbers and annual income of a group of people.

data1.txt Bob, 555-1234 Matthew, 555-2345 Mark, 555-3456 Luke, 000-1234 John, 000-2345

data2.txt Matthew, 000000001 Mark, 000000002 Luke, 000000003 Joe, 000000004

data3.txt 000000001, 55000 000000003, 65000 000000004, 70000 000000007, 10000000

 d1 = []
 d2 = []
 d3 = []

data1 = open("data1.txt", "r")
for line in d1:
d1 = line.split(":")
name = d1[0]
number = int(d1[1])

data2 = open("data2.txt", "r")
for line in d2:
d2 = line.split(":")
name = d2[0]
ssnumber = int(d2[1])

data3 = open("data3.txt", "r")
for line in d3:
d3 = line.split(":")
ssnumber = d3[0]
income = d3[1]

l = []
for x in d2:
    for y in d3:
        if x[1] in y:
newfile = []
for x in d1:
    for y in l:
        if x[0] in y:
            newfile.append((x[1], y[0], *y[1]))

tnumber = input("Enter a telephone number including dash: ")

position = 0 
for data in newfile:
    if data[0] == tel:
        position = 1
    print("Telephone number:" , tnumber)
    print("Name: ", data[1])
    print("Social Security number ", data[2])
    print("Annual Income: ", data[3])
if position == 0:
    print("There is no data for the telephone number entered")

After I run my code, I get the prompt for user input of a telephone number, I enter the 7 digit telephone number including the dash (-), but after I press enter the program stops running and there are no errors. Does anyone know why this is?

Read more here: https://stackoverflow.com/questions/67374936/write-a-program-that-queries-information-from-three-files-program-should-ask-fo

Content Attribution

This content was originally published by Sam at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: