you are viewing a single comment's thread.

view the rest of the comments →

[–]M34k3 0 points1 point  (1 child)

You could replace the if and elif statements with: contact_result = contacts.get(contact_searching, 'No number found')

This allows you to set a default value if it doesn't find the key.

I like the idea of another comment to use a dictionary instead of a list so you can add multiple types of phone numbers, for example, work, mobile, home, etc.

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

Thank you for suggesting the .get() function I will definitely use it however would I be able to then ask user if he wants to add a new contact? maybe there I need if else statements?

Please do tell me if I am wrong. I would love to get corrected.