{
"Items128": 7,
"Item29": 3,
"Item32": 17,
"Item45": 0,
"Item93": 4
}
for row in cursor.execute(f"SELECT invent FROM inv where id={ctx.author.id}"):
data=json.loads(row[0])
num =...
import json
data = '''{
"Items128": 7,
"Item29": 3,
"Item32": 17,
"Item45": 0,
"Item93": 4
}'''
items_dict = json.loads(data)
item_numbers = dict((number, key) for number, key in enumerate(items_dict.keys()))
while True:
for number, item in item_numbers.items():
print(f'item {number} - {item}')
my_number = input('выбери номер:')
try:
my_number = int(my_number)
if my_number in item_numbers.keys():
print(f'{item_numbers[my_number]}: {items_dict[item_numbers[my_number]]}')
else:
print('--- нет такого номера ---')
except ValueError:
print(f'--- "{my_number}" - это не номер! ---')