python - Removing Text and Comparing Integers within Strings -
due original post being filled flamers assuming i'm asking them write code me , refusing answer me @ all, i'm reposting question.
i stress fact total beginner @ python, , not here ask people write me, i'm trying ascertain method , guidance on how approach problem, because i'm having real difficulty approaching it, , seems think i'm asking them give me code need, , i'm not.
so, on original question.
my problem follows, have made mathematics quiz, outputs name , score text file. in program, plan add code @ beginning, run list of options compare , order results text file. program imports entries list, , format follows:
['john : 6', 'bob : 9', 'billy : 2', 'matthew : 7', 'jimmy : 2', 'amy: 9', 'jenny : 10', 'michael : 8']
python recognizes list 8 items, perfect. has name, , score. problem specification i'm working requires me able to:
sort in alphabetical order each student's highest score tests.
also, highest score, , average score. i've tried many hours in order find code can compare integers within these strings each other find highest score, , print one, i've had no luck. feel struggle other 2 tasks, , wish guidance.
i thought possibly using slices in order take integer separate value in order compare them, felt make code messy quickly.
you try split strings on " : " , convert number int int("2")
.
the result can put in dictionary:
d = {} d['john'] = 6
if have item (if x in d:
), compare old value , new value.
Comments
Post a Comment