-3

I have a problem with the dictionary

I don't know how to convert keys to values

I tried to find way to solve this problem on the internet but I didn't understand

Expect: "I": 1 => 1:"I" convert = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000,} new_dict ={} for k,v in convert.items(): new_dict.update({v,k}) 
3
  • 3
    You say "args to kwargs", but what you're actually showing is swapping keys and values. Commented Jan 5, 2021 at 7:52
  • oh sorry so what "args to kwargs" mean? Can you explain it for me? Commented Jan 5, 2021 at 8:40
  • See e.g. stackoverflow.com/questions/287085/what-do-args-and-kwargs-mean Commented Jan 5, 2021 at 8:43

1 Answer 1

1

args and kwargs are totally different things and related to something else not values and keys of dictionary..

Now, for what you're asking, you can check this code to achieve what you were asking,

Code Syntax

convy = {value: key for key, value in convert.items()} 

Output

{1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M', 4: 'IV', 9: 'IX', 40: 'XL', 90: 'XC', 400: 'CD', 900: 'CM'} [Program finished] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.