I'm setting up a list of baseball players in which their stats are being shown and I want to support queries request by input of the users. For example if the user wants to look up a player and only knows a part of the name and runs it, that the code I wrote down can still find the player in the list containing those letters.
I can't seem to find the right combination of the for-loops and if-statements.
I have tried the following code:
all_players = the list
for player in all_players:
request_player = input("Please provide the name of the player you want to look up? ")
if request_player in all_players:
print(all_players)
else:
print("No player with that name was found.")
I expect that if a player's name is Miquel Andujar and he is on the list, that if I write down "miqu" as input. That I get all the matching names containing "miqu".
But with the code above I only get the "No player with that name was found." back.