Python
4
Вклад в тег
num_set = set()
x = 1
while x != 0:
x=int(input('введите число '))
num_set.add(x)
num_set.remove(max(num_set))
print(max(num_set))
result = [('Moscow', 'Ivanova', '10',) , ('Moscow', 'Ivanova', '13a',) , ('Moscow', 'Ivanova', '2') ......]
import json
import collections as col
rows_from_DB = [('Moscow','Lomonosova','14',), ('Moscow','Lomonosova','15a',), ('Omsk','Ivanova','4',), ('Moscow','Kotlyara','7',), ('Sochi','Zhukova','11b',)]
cities = col.defaultdict()
for row in rows_from_DB:
if row[0] not in cities:
cities[row[0]] = col.defaultdict()
if row[1] not in cities[row[0]]:
cities[row[0]][row[1]] = []
cities[row[0]][row[1]].append(row[2])
print(json.dumps(cities))
{
"Omsk": {
"Ivanova": ["4"]
},
"Moscow": {
"Kotlyara": ["7"],
"Lomonosova": ["14", "15a"]
},
"Sochi": {
"Zhukova": ["11"]
}
}