Syntax Error Python 3 When Calling Function -
i cannot understand why keep getting syntax error in python 3 program on line 78. trying call function 2 parameters.
reporthits(playerlist, num)
i have checked indents, spacing, colons, , looked online nothing have done has fixed it.
any appreciated!
def quit(): """this function quits baseball database""" print("you leaving baseball database") print("program terminating gracefully...") def help(): """this function displays list of program functions user""" print("quit - exit progam") print("help - display list of functions") print("input - input file_path") print("team - sort baseball database team name identifier") print("report - sort baseball database number of hits") def filepath(): """this function allows users input file""" fileobject = input("please enter file path read: ") return fileobject def processinput(filepath): """this function processes input file""" filehandle = open(fileobject, "r") playerlist = [] line in filehandle: line = line.strip() tokens = line.split(";") element = {"name":tokens[0].lower().strip(), "team":tokens[1].lower().strip(), "gamesplayed":int(tokens[2]), "atbats":int(tokens[3]), "runsscored":int(tokens[4]), "hits":int(tokens[5]), "doubles":int(tokens[6]), "triples":int(tokens[7]), "homeruns":int(tokens[7])} playerlist.append(element) filehandle.close() return playerlist def reporthits(sortlist, n): """this function sorts each dictionary in playerlist 'hits'""" operator import itemgetter listhits = sorted(sortlist, key = itemgetter('hits'), reverse = true) table = listhits n in table[ :n]: tabulate import tabulate print(tabulate(table, headers="keys", tablefmt="grid")) def sortteams(sortlist): """this function sort each dictionary in playerlist 'team'""" operator import itemgetter listteams = sorted(sortlist, key = itemgetter('team')) table = listteams tabulate import tabulate print(tabulate(table, headers="keys", tablefmt="grid")) playerlist = none command = none print("welcome baseball database") while command != "quit": command = input("please enter command (type list acceptable commands):") command = command.strip() command = command.lower() if command.startswith("quit"): quit() elif command.startswith("help"): help() elif command.startswith("input"): fileobject = filepath() tokens = fileobject.split(" ") playerlist = processinput(tokens) print("input file has been processed") elif command.startswith("team"): if playerlist != none: sortteams(playerlist) else: print("no players have been added list") print("please input file before using 'team' command") elif command.startswith("report"): if playerlist != none: num = input(float("how many of top players want view?") reporthits(playerlist, num) else: print("no players have been added list") print("please input file before using 'report' command") else: print("user entered unrecognized command")
num = input(float("how many of top players want view?") reporthits(playerlist, num)
you missing close parenthesis on previous line.
Comments
Post a Comment