Procurando por um título que 'comece com' em python?
Então eu tenho uma lista de nomes
name_list = ["John Smith", "John Wrinkle", "John Wayne", "David John", "David Wrinkle", "David Wayne"]
Quero poder pesquisar, por exemplo,John
e
John Smith
John Wrinkle
John Wayne
Exibirá. No momento, meu código exibirá
John Smith
John Wrinkle
John Wayne
David John
O que estou fazendo errado?
Aqui está o meu código
search = input(str("Search: "))
search = search.lower()
matches = [name for name in name_list if search in name]
for i in matches:
if(search == ""):
print("Empty search field")
break
else:
i = i.title()
print(i)