michael_flaherty_ps5_contactManager

.py

School

Stockton University *

*We aren’t endorsed by this school

Course

2210

Subject

Computer Science

Date

Oct 30, 2023

Type

py

Pages

1

Uploaded by JudgeRoseWalrus50

# Initialize the list of contacts as a list of lists with starting data contacts = [ ["Guido van Rosswn", "guido@python.org", "+31 10 1234 5678"], ["Eric Idle", "eric@ericidle.com", "+44 20 7946 0958"] ] # Main program loop while True: print("Contact Manager") print("COMMAND MENU") print("list - Display all contacts") print("view - View a contact") print("add - Add a contact") print("del - Delete a contact") print("exit - Exit program") command = input("Command: ") if command == "list": # Display the list of contacts for i, contact in enumerate(contacts, start=1): print(f"{i}. {contact[0]}") elif command == "view": try: contact_number = int(input("Number: ")) - 1 if 0 <= contact_number < len(contacts): contact = contacts[contact_number] print(f"Name: {contact[0]}") print(f"Email: {contact[1]}") print(f"Phone: {contact[2]}") else: print("Invalid contact number.") except ValueError: print("Invalid input. Please enter a valid number.") elif command == "add": name = input("Name: ") email = input("Email: ") phone = input("Phone: ") new_contact = [name, email, phone] contacts.append(new_contact) print(f"{name} was added.") elif command == "del": try: contact_number = int(input("Number: ")) - 1 if 0 <= contact_number < len(contacts): deleted_contact = contacts.pop(contact_number) print(f"{deleted_contact[0]} was deleted.") else: print("Invalid contact number.") except ValueError: print("Invalid input. Please enter a valid number.") elif command == "exit": print("Bye!") break else: print("Invalid command. Please enter a valid command.")
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: (a) How many such chain molecules are there? [Hint: If the three A's were distinguishable from one…
Q: military legacies of the Korean War and how they affected the subsequent course of military…
Q: The "Great Dying" among the native peoples of the Americas made it easier for European powers to…
Q: 1. A ball is launched from the ground with an initial velocity of 6.4 m/s at an angle of 60° above…
Q: The burning rates of two types of propellants used in aircrew escape systems are being studied. It…
Q: Water is poured into a cylindrical tank, and then a spout at the base of the tank is opened so that…
Q: The presence of bacteria in a urine sample (bacteriuria) is sometimes associated with symptoms of…
Q: A U.S. $1 bill was valued at 1.256 Canadian dollars in February 2018. What was the value of 27.32…
Q: Find the perimeter of a square whose side length is described by the expression 2m- 3
Q: One kilogram on a diatomic ideal gas undergoes the following four step process starting at Point A…
Q: 1. Logistic regression with ±1 labels. Logistic regression (with ±1 labels) maximizes the likelihood…
Q: Find the equation of the hyperbola shown below. Q Q 1₁--9- 17 ਰਿਹਾ ਹੈ What is the equation for this…
Q: 2. When you move the slide to the left with the stage controls, how does it appear to move through…
Q: 2. A soccer player kicks a ball at a speed of 45.5 miles per hour at an angle of 39.5° up from…
Q: An 2100 kg asteroid travels through space at a constant 5 km/s in the +y direction. An alien…
Q: 15) Find the slope of a line with the equation of y=-3 a. -1/2 b. ¹/2 c. 3 16) Solve the following…
Q: <++++ -10-9-8-7-6-5-4-3-2 10- 9 8 Provide your answer below: it + 7 6 5 4 3+ 2 -5 (0,2√6) -8- -9 ++…
Q: One painter can paint a house in 7 days, yet a more experienced painter can paint the house in 5…
Q: Given that f(x) = x² + 7x and g(x) = x - 3, calculate (a) fog(-5)= (b) go f(-5)= Question Help:…
Q: You are working out on a rowing machine. Each time you pull the rowing bar (which simulates the…
Q: 0% class A, 20% class B, 50% class C, and 20% class D. What is the CPI for P2?
Q: 4. Use the graph to calculate the limits. You may assume that one square represents one unit on the…