Please write the code in PYTHON and read the bold instructions!!! Imagine there
ID: 3784565 • Letter: P
Question
Please write the code in PYTHON and read the bold instructions!!!
Imagine there is a class called Person, and the Person has a private attribute called name. Write a method for the person class that takes as argument a substring of length less than or equal to three, and returns the location of the substring in the Person's name (or -1 if it doesn't exist). For example, if the name is "Jonson" and the substring is "ons", your method would return 1. You may not use any built in functions/methods besides len () and. append() You don't need to write the whole class, just the | method.Explanation / Answer
def find_sub(self,sub):
if len(name) <= 3:
return name.find(sub)
else:
return -1