How to add just key in dict? [on hold]












0












$begingroup$


I have some dict to add:



p = {('S', 'A'): (2, 2)}
x = {'D' : (3, 3)}



my code is:



p.update(x)
print(p)



output:
{('S', 'A'): (2, 2), 'D': (3, 3)}



but, my expected output is:
{('S', 'A', 'D'): (5, 5)}










share|improve this question







New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by Dawny33 17 hours ago



  • This question does not appear to be about data science, within the scope defined in the help center.

If this question can be reworded to fit the rules in the help center, please edit the question.
















  • $begingroup$
    You are not adding anything, right? You are changing the key, as I understand from your question
    $endgroup$
    – Dawny33
    18 hours ago










  • $begingroup$
    yes for values. i just update a dict. sum of values is not yet.
    $endgroup$
    – lilis gumilang
    18 hours ago










  • $begingroup$
    Hi @lilisgumilang, this question seems to be about programming and not about data science. Therefore, it would be better if you ask it in stackoverflow.
    $endgroup$
    – ncasas
    17 hours ago










  • $begingroup$
    The update method is doing what it should. You want to actually change the dictionary key by updating the tuple. You cannot do that directly, as dict keys (as a necessity) are immutable (unchangeable).
    $endgroup$
    – n1k31t4
    12 hours ago
















0












$begingroup$


I have some dict to add:



p = {('S', 'A'): (2, 2)}
x = {'D' : (3, 3)}



my code is:



p.update(x)
print(p)



output:
{('S', 'A'): (2, 2), 'D': (3, 3)}



but, my expected output is:
{('S', 'A', 'D'): (5, 5)}










share|improve this question







New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as off-topic by Dawny33 17 hours ago



  • This question does not appear to be about data science, within the scope defined in the help center.

If this question can be reworded to fit the rules in the help center, please edit the question.
















  • $begingroup$
    You are not adding anything, right? You are changing the key, as I understand from your question
    $endgroup$
    – Dawny33
    18 hours ago










  • $begingroup$
    yes for values. i just update a dict. sum of values is not yet.
    $endgroup$
    – lilis gumilang
    18 hours ago










  • $begingroup$
    Hi @lilisgumilang, this question seems to be about programming and not about data science. Therefore, it would be better if you ask it in stackoverflow.
    $endgroup$
    – ncasas
    17 hours ago










  • $begingroup$
    The update method is doing what it should. You want to actually change the dictionary key by updating the tuple. You cannot do that directly, as dict keys (as a necessity) are immutable (unchangeable).
    $endgroup$
    – n1k31t4
    12 hours ago














0












0








0





$begingroup$


I have some dict to add:



p = {('S', 'A'): (2, 2)}
x = {'D' : (3, 3)}



my code is:



p.update(x)
print(p)



output:
{('S', 'A'): (2, 2), 'D': (3, 3)}



but, my expected output is:
{('S', 'A', 'D'): (5, 5)}










share|improve this question







New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I have some dict to add:



p = {('S', 'A'): (2, 2)}
x = {'D' : (3, 3)}



my code is:



p.update(x)
print(p)



output:
{('S', 'A'): (2, 2), 'D': (3, 3)}



but, my expected output is:
{('S', 'A', 'D'): (5, 5)}







python






share|improve this question







New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 19 hours ago









lilis gumilanglilis gumilang

6




6




New contributor




lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






lilis gumilang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Dawny33 17 hours ago



  • This question does not appear to be about data science, within the scope defined in the help center.

If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by Dawny33 17 hours ago



  • This question does not appear to be about data science, within the scope defined in the help center.

If this question can be reworded to fit the rules in the help center, please edit the question.












  • $begingroup$
    You are not adding anything, right? You are changing the key, as I understand from your question
    $endgroup$
    – Dawny33
    18 hours ago










  • $begingroup$
    yes for values. i just update a dict. sum of values is not yet.
    $endgroup$
    – lilis gumilang
    18 hours ago










  • $begingroup$
    Hi @lilisgumilang, this question seems to be about programming and not about data science. Therefore, it would be better if you ask it in stackoverflow.
    $endgroup$
    – ncasas
    17 hours ago










  • $begingroup$
    The update method is doing what it should. You want to actually change the dictionary key by updating the tuple. You cannot do that directly, as dict keys (as a necessity) are immutable (unchangeable).
    $endgroup$
    – n1k31t4
    12 hours ago


















  • $begingroup$
    You are not adding anything, right? You are changing the key, as I understand from your question
    $endgroup$
    – Dawny33
    18 hours ago










  • $begingroup$
    yes for values. i just update a dict. sum of values is not yet.
    $endgroup$
    – lilis gumilang
    18 hours ago










  • $begingroup$
    Hi @lilisgumilang, this question seems to be about programming and not about data science. Therefore, it would be better if you ask it in stackoverflow.
    $endgroup$
    – ncasas
    17 hours ago










  • $begingroup$
    The update method is doing what it should. You want to actually change the dictionary key by updating the tuple. You cannot do that directly, as dict keys (as a necessity) are immutable (unchangeable).
    $endgroup$
    – n1k31t4
    12 hours ago
















$begingroup$
You are not adding anything, right? You are changing the key, as I understand from your question
$endgroup$
– Dawny33
18 hours ago




$begingroup$
You are not adding anything, right? You are changing the key, as I understand from your question
$endgroup$
– Dawny33
18 hours ago












$begingroup$
yes for values. i just update a dict. sum of values is not yet.
$endgroup$
– lilis gumilang
18 hours ago




$begingroup$
yes for values. i just update a dict. sum of values is not yet.
$endgroup$
– lilis gumilang
18 hours ago












$begingroup$
Hi @lilisgumilang, this question seems to be about programming and not about data science. Therefore, it would be better if you ask it in stackoverflow.
$endgroup$
– ncasas
17 hours ago




$begingroup$
Hi @lilisgumilang, this question seems to be about programming and not about data science. Therefore, it would be better if you ask it in stackoverflow.
$endgroup$
– ncasas
17 hours ago












$begingroup$
The update method is doing what it should. You want to actually change the dictionary key by updating the tuple. You cannot do that directly, as dict keys (as a necessity) are immutable (unchangeable).
$endgroup$
– n1k31t4
12 hours ago




$begingroup$
The update method is doing what it should. You want to actually change the dictionary key by updating the tuple. You cannot do that directly, as dict keys (as a necessity) are immutable (unchangeable).
$endgroup$
– n1k31t4
12 hours ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to label and detect the document text images

Vallis Paradisi

Tabula Rosettana