blob: cdcc62214188eb2db686cb36592889d8affda182 (
plain)
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
37
38
39
40
41
42
|
toWrite = """Sword,5
Mace,3
Warhammer,8
Shield,1
Spear,6
"""
def getLowest(list):
lowest = 1000
for i in list:
if i < lowest:
lowest = i
return lowest
f = open("./items", "w")
f.write(toWrite)
f.close()
f = open("./items", "r")
items = []
for i in f.readlines():
tmp = []
tmp.append(i.split(",")[0])
tmp.append(int(i.split(",")[1].strip("\n ")))
items.append(tmp)
amounts = []
for i in items:
amounts.append(i[1])
sorted = []
for x in range(len(items)):
for i in items:
if i[1] == getLowest(amounts):
sorted.append(i[0])
items.remove(i)
amounts.remove(getLowest(amounts))
print(*sorted, sep=" ")
|