Created
April 4, 2021 03:48
-
-
Save Markj89/beab716bea839915a24104a7efcb2fe1 to your computer and use it in GitHub Desktop.
Python Contact Book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names = [] | |
phone_numbers = [] | |
num = 2 | |
for i in range(num): | |
name = input("Name: ") | |
phone_number = input("Phone Number: ") | |
names.append(name) | |
phone_numbers.append(phone_number) | |
print("\nName\t\tPhone Number\n") | |
for i in range(num): | |
print("{}\t\t\t{}".format(names[i], phone_numbers[i])) | |
f = open("contacts.txt", "a") | |
f.writelines("{}\t\t\t{}\n".format(names[i], phone_numbers[i])) | |
f.close() | |
search_term = input("\nEnter Search Term: ") | |
print("Search Result") | |
if search_term in names: | |
index = names.index(search_term) | |
phone_number = phone_numbers[index] | |
print("Name: {}, Phone Number: {}".format(search_term, phone_number)) | |
else : | |
print("Name not found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment