Advertisements
Advertisements
प्रश्न
Write a program to search input any customer name and display customer phone number if the customer name is exist in the list.
कोड लेखन
Advertisements
उत्तर
Store customer name and phone number as key-value pairs in a dictionary, then search the customer name.
n = int(input("Enter number of customers: "))
customers = {}
for i in range(n):
name = input("Enter customer name: ")
phone_number = input("Enter phone number: ")
customers[name] = phone_number
search_name = input("Enter customer name to search: ")
if search_name in customers:
print("Customer phone number:", customers[search_name])
else:
print("Customer name does not exist")
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
