class Players: def __init__(self, full_name, goals, shots, headers, tackles, passes, clean_sheets): self.nm = full_name self.gl = goals self.st = shots self.hd = headers self.tk = tackles self.ps = passes self.cs = clean_sheets morelos = Players('Alfredo Morelos', 35, 10, 5, 5, 6, 10) kent = Players('Ryan Kent', 20, 10, 7, 5, 6, 8) defoe = Players('Jermaine Defoe', 30, 6, 5, 5, 6, 8) tav = Players('James Tavernier', 4, 6, 7, 7, 5, 6) mcgregor = Players('Allan McGregor', 20, 5, 5, 6, 7, 6) barisis = Players('Borno Barisic', 10, 30, 3, 5, 6, 10) goldson = Players('Conor Goldson', 20, 10, 7, 5, 6, 8) katic = Players('Nikola Katic', 30, 6, 5, 5, 6, 8) jack = Players('Ryan Jack', 4, 6, 7, 7, 5, 6) davis = Players('Steve Davis', 20, 5, 5, 6, 7, 6) def statistic_grab(): if player_name == 'am' and player_stat == 'goals': print(morelos.nm, 'has scored', morelos.gl, 'goals') elif player_name == 'am' and player_stat == 'shots': print(morelos.nm, 'has taken', morelos.st, 'shots') elif player_name == 'am' and player_stat == 'headers': print(morelos.nm, 'has made', morelos.hd, 'headers') elif player_name == 'rk' and player_stat == 'goals': print(kent.nm, 'has scored', kent.st, 'goals') elif player_name == 'rk' and player_stat == 'headers': print(kent.nm, 'has made', kent.hd, 'headers') elif player_name == 'rkdefoe' and player_stat == 'shots': print(kent.nm, 'has taken', kent.st, 'shots') elif player_name == 'jd' and player_stat == 'headers': print(defoe.nm, 'has made', defoe.hd, 'headers') elif player_name == 'jd' and player_stat == 'goals': print(defoe.nm, 'has scored', defoe.st, 'goals') elif player_name == 'jdtav' and player_stat == 'headers': print(defoe.nm, 'has made', defoe.hd, 'headers') elif player_name == 'jt' and player_stat == 'goals': print(tav.nm, 'has scored', tav.st, 'goals') elif player_name == 'jt' and player_stat == 'headers': print(tav.nm, 'has made', tav.hd, 'headers') elif player_name == 'jt' and player_stat == 'shots': print(tav.nm, 'has taken', tav.st, 'shots') else: print("Invalid input") print('Welcome to Rangers Player Statistics\n') new_stat = input('Would you like to choose a stat? \n') while new_stat == 'yes': print('The players we have statistics for are:\nAlfredo Morelos\nRyan Kent\nJermaine Defoe\nJames Tavernier\n' 'Allan McGregor\nBorno Barisic\nConor Goldson\nNikola Katic\nRyan Jack\nSteve Davis\n') player_name = input('Which player would you like statistics on? (please enter player initials) \n') player_stat = input('Which statistic would you like?\nGoals\nShots\n Headers \n') statistic_grab() new_stat = input('Would you like another stat? \n') if new_stat == 'no': print('Thank you, Goodbye') break elif new_stat == 'yes': continue else: new_stat = input('Invalid input, please enter yes or no: \n') if new_stat == 'no': print('Thank you, Goodbye') break elif new_stat == 'yes': continueMy question is about the statistic_grab section, the whole code has complete functionality at the minute
but I'm unsure what function or method I should use to make my code efficient. As you can see, only some
of the data needed is in the code at present and its already getting ridiculously repetitive. All I am after is
guidance on what to use then I want to research how to use it and implement myself. Thank you in advance :)