You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Deze repo is gearchiveerd. U kunt bestanden bekijken en het klonen, maar niet pushen of problemen/pull-requests openen.

5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. def parse_scores():
  2. res = dict()
  3. with open("scores.txt") as file:
  4. for line in file.readlines():
  5. name, score = line.split()
  6. res[name] = int(score)
  7. return res
  8. scores = { "joe" : 42, "jack" : 43 }
  9. print (convert(scores))
  10. def print_scores(scores):
  11. print("Tableau des résultats:")
  12. for name, score in scores.items():
  13. print(name, score)
  14. def convert(scores):
  15. res = ""
  16. for name, score in scores.items():
  17. res += name + " " + str(score) + "\n"
  18. return res
  19. def register_score(scores, name, new_score):
  20. # Mise à jour des tableaux des scores
  21. # Et écriture dans un fichier
  22. scores[name] = new_score
  23. with open("scores.txt", "w") as file:
  24. file.write(convert(scores))
  25. def main():
  26. scores = parse_scores()
  27. name = input("nom: ")
  28. new_score = input("score: ")
  29. register_score(scores, name, new_score)
  30. print_scores(scores)
  31. main()