I have a list/array called position[] and it is used to store the position line number of the string by using find(). The string is the abc.py which is a python file(I will include the abc.py below).
Question: how do find the string position of all def.
Objective: capture the line number of the first def and the second def and third etc and stored it in position[]
abc.py:
 #!C:\Python\Python39\python.exe
    # print ('Content-type: text/html\n\n')
def hello_step0():
    create()
    login()
def hello2_step1():
    delete()
def hello2_step2():
    delete()
What i did to find the first occurrence of def
position = [] 
with open("abc.py","r") as file:
    line = file.readlines()
    line = str(line)
    print(line.strip().find("def")) # output 102
    position.append(line.strip().find("def"))