-3

Zip the gender and category into dictionary

gender ={ 'Male','Female','Transgender'}
category={'boy','girl','boy_and_girl'}
updated_list = dict(zip(gender,category))
print(updated_list)

Expected output:

{'Male': 'boy_and_girl', 'Transgender': 'girl', 'Female': 'boy'}
  • Already has an answer here https://stackoverflow.com/questions/209840/how-do-i-convert-two-lists-into-a-dictionary – Mr. J Feb 26 '21 at 11:48
  • Does this answer your question? [How do I convert two lists into a dictionary?](https://stackoverflow.com/questions/209840/how-do-i-convert-two-lists-into-a-dictionary) – Mr. J Feb 26 '21 at 11:48

1 Answers1

2

gender and category should be lists, not sets, as sets are not sorted data structures. Try:

gender =[ 'Male','Female','Transgender']
category=['boy','girl','boy_and_girl']
updated_list = dict(zip(gender,category))
print(updated_list)
tino
  • 160
  • 6