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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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() |