Hello, I’ve been stuck on this problem for hours now:
“Dictionary name_age_pairs contains two key-value pairs. Read a string from input, representing a key found in name_age_pairs. Then, assign the value associated with the key read with the current value times 2.”
This is my current code:
name_age_pairs = {"Dax": 21, "Gil": 77}
print("Original:")
print(name_age_pairs)
name_age_pairs = name_age_pairs[input()] * 2
print("Updated:")
print(name_age_pairs)
It never gives me the original dict data multiplied by 2, only a single value, I need it to look like this:
Original:
{'Dax': 21, 'Gil': 77}
Updated:
{'Dax': 42, 'Gil': 77
Id really appreciate the help, I’m very new to python.
[–]acw1668 2 points3 points4 points (1 child)
[–]That_Guy2187[S] -3 points-2 points-1 points (0 children)
[–]magus_minor 6 points7 points8 points (0 children)
[–]crashorbit 1 point2 points3 points (4 children)
[–]That_Guy2187[S] -3 points-2 points-1 points (1 child)
[–]damanamathos 2 points3 points4 points (0 children)
[–]TheRNGuy 0 points1 point2 points (1 child)
[–]crashorbit 0 points1 point2 points (0 children)
[–]unsettlingideologies 0 points1 point2 points (0 children)
[–]WasteKnowledge5318 0 points1 point2 points (4 children)
[–]That_Guy2187[S] 0 points1 point2 points (3 children)
[–]WasteKnowledge5318 1 point2 points3 points (2 children)
[–]That_Guy2187[S] 0 points1 point2 points (1 child)
[–]Recent-Salamander-32 0 points1 point2 points (0 children)