File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,14 @@ def add_contact(self):
45
45
46
46
47
47
def fetch_contact (self ,first_name ):
48
+ """
49
+ Description :
50
+ This function fetches contact from contact list uing first name.
51
+ Parameters :
52
+ first_name : first name of the contact to remove.
53
+ Returns :
54
+ contact : contact from contacts list.
55
+ """
48
56
for contact in self .contacts :
49
57
if contact .first_name == first_name :
50
58
return contact
@@ -79,7 +87,28 @@ def update_contact(self,first_name):
79
87
else :
80
88
input ("Contact not found. Hit enter to continue" )
81
89
82
- # display address Book
90
+
91
+ # remove contact from address Book
92
+ def remove_contact (self ,first_name ):
93
+ """
94
+ Description :
95
+ This function checks if the first name in present in contact
96
+ if it is present, take the inputs from user again ,find the index number and update the contact.
97
+ Parameters :
98
+ self : self.contacts list.
99
+ Returns :
100
+ none
101
+ prints update message.
102
+ """
103
+ contact = self .fetch_contact (first_name )
104
+ if contact :
105
+ self .contacts .remove (contact )
106
+ print ("Contact removed successfully" )
107
+ else :
108
+ input ("Contact not found. Hit enter to continue" )
109
+
110
+
111
+ # display contacts from address Book
83
112
def display_contact (self ):
84
113
"""
85
114
Description :
You can’t perform that action at this time.
0 commit comments