dataset - Storing two linked values in Python -
i understand there's different ways of storing data in python can't figure use needs.
i've made small client/server game, , want amount of guesses took them score. write name (currently ip address) along score file create list of high scores. while can fine, want maximum of 5 scores stored , able sort them when display high scores , names user, lowest (being best score) @ top. i'd allow username exist more once.
while it's easy write data , read it, can't figure out data type use, dictionary make lot of sense in cases, key can have 1 value , key can exist once, list has no relation other specific values contained within neither make sense use, , tuples can't sorted either seems.
i thinking reading each line sperate list , using index compare score sort them , write file, bad on memory in opinion?
what easiest method save name , score without using extreme learning curve sql?
you can store list of tuples each tuple containing data in particular order (eg. score, name etc). can sort list using list.sort() function defining function f compare scores , passing function in sort().
Comments
Post a Comment