S
S
SHADRIN2020-06-06 09:36:38
Python
SHADRIN, 2020-06-06 09:36:38

How to update dictionary value?

users = {}
users[1611531] = ('Иван', 'Иванович', '55555')


How to update a certain value, let's change the Patronymic name?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SHADRIN, 2020-06-06
@shadrin_ss

For those who need an answer.

from collections import defaultdict
users = defaultdict(list)

users[1].append('Часы')
users[1].append('Очки')
users[1].append('Одежда')

print (users[1])

users[1][0] = ('Новое значение')

print (users[1])

A
Alexander, 2020-06-06
@NeiroNx

Do it better like this:

users = {}
user[1611531] = {"name":"Иван","family":"Иванов","sname":"Иванович","money":55555}
user[1611531]["sname"] = "Петрович"

in parentheses is tuple . The structure is very limited and inconvenient. Unless it takes up little memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question