251def search_for_user(user_id):
2# read all lines from the file
3with open("users.txt") as f:
4file_contents = f.read()
5
6# get a list of rows
7users = file_contents.split("\n")
8
9# extract user info
10for user in users:
11id, first_name, last_name, ip_address = user.split("\t")
12if id == user_id:
13return id, first_name, last_name, ip_address
14
15running = True
16while running:
17id_to_search_for = input("Enter a user id (1-100):")
18# search for the user from the file
19if id_to_search_for.isnumeric():
20id, first_name, last_name, ip_address = search_for_user(id_to_search_for)
21print("user with ID " + id + " is:", first_name, last_name, ip_address)
22# if the user doesn't enter a number, stop the program
23else:
24running = False
25