-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (25 loc) · 769 Bytes
/
main.py
File metadata and controls
36 lines (25 loc) · 769 Bytes
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
from replit import db
import operator
def contains(value):
for x in db.keys():
if (db[x] == value):
return True
return False
def delete():
for x in db.keys():
del db[x]
username = input("Enter your username: ")
while (contains(username)):
username = input("Already exists. Enter another username: ")
num = int(input("Enter a number: "))
while (num >= 2000 or num <= -2000):
num = int(input("Number needs to be less than 2000 and greater than -2000. Enter another number: "))
db[username] = num
print("------------------------------------")
print("LEADERBOARD")
arr = {}
for x in db.keys():
arr[x] = int(db[x])
sort = sorted(arr.items(), key=operator.itemgetter(1), reverse=True)
for value,x in sort:
print(str(x) + ": " + value)