how to create a leaderboard on python 3.8.1 1

how to create a leaderboard on python 3.8.1

# leaderboard = []
f = open('Leaderboard.txt', 'r')
leaderboard = [line.replace('\n','') for line in f.readlines()]


for i in leaderboard:
    print(i)

Here is what the above code is Doing:
1. Open the file in read mode
2. Read the file line by line
3. Replace the newline character with an empty string
4. Append the line to the leaderboard list
5. Close the file

Similar Posts