I need to create a code that will extract the dob from a array of string, like this finddob(["name:bob grade:a dob:1980","dob:1976 name:kate grade:c"])
def finddob(listofstrings):
recordnum = 0
while(recordnum < len(listofstrings)):
yearstart = listofstrings[recordnum].find("dob:") + 4
yearend = listofstrings[recordnum].find(yearend)
year = int(listofstrings[yearstart, yearend])
if(year > 1990):
print("Is over 21")
else:
print("Is under 21")
recordnum = recordnum + 1
but i get the error above, any help would be appreciated