English

Write a program to input n customer name and phone numbers.

Advertisements
Advertisements

Question

Write a program to input n customer name and phone numbers.

Code Writing
Advertisements

Solution

Use a dictionary to store customer name as the key and phone number as the value.

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

print(customers)
 
shaalaa.com
  Is there an error in this question or solution?
Chapter 1: Review of Phython - EXERCISE [Page 27]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 1 Review of Phython
EXERCISE | Q 29. | Page 27
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×