Jan-14-2018, 10:18 PM
Hi,
Is there a way to write my code more simple, more readable, cleaner. I need all the help I can get. Im headed to germany for a famillie reunion and my flight departs within a few hours, i will be back online as soon as i can get a connection.
Is there a way to write my code more simple, more readable, cleaner. I need all the help I can get. Im headed to germany for a famillie reunion and my flight departs within a few hours, i will be back online as soon as i can get a connection.
import csv def read(): a = open("casus.csv", "r") areader = csv.reader(a) list_to_order = [] reversed_list = [] print("score: team:\n") for row in areader: if len(row)!=0: temp_list = [] temp_list.append(int(row[1])) temp_list.append(row[0]) list_to_order.append(temp_list) list_to_order.sort() length = len(list_to_order) for i in range (length): reversed_list.append(list_to_order[length-1-i]) for row in reversed_list: print (str (row[0])+" "+row[1]) input("\n press button to go back to menu") menu() def add(): team = input("team: ") score = input("score: ") a = open('casus.csv','a') awriter = csv.writer(a) awriter.writerow([team,score]) a.close() menu() def menu(): answer = input("\n################MENU################\npress 1 to add a team with the scores." "\npress 2 to generate a ranking list\n press 3 to close. ") if answer == "1": add() elif answer == "2": read() elif answer == "3": exit() menu()