-3

[( The word ‘Women Empowerment’ itself implies that women are not powerful enough - they need to be empowered., 0.125), (This painful truth has been in existence for a long long time., 0.16666666666666666), (It is in recent years that noticeable work started beginning to lift women out of the abyss of insignificance and powerlessness., 0.09090909090909093), (The patriarchal society suppressed women’s freedom across the world., 0.16666666666666666), (Women were not allowed to vote or even put forward any opinion., 0.2), (Women were confined to their homes., 0.3333333333333333), (As time progressed, they realised that their life meant much more than just serving in the household., 0.14285714285714282), (As more and more women started crossing the man-made barriers, the world began to witness the rise of women., 0.09999999999999999), (Unlike men, women never try to stifle the voice of their opposite gender., 0.125), (They hold the hands of all the downtrodden people - men and women both - and they pull them out of misfortune as they try to improve their lives., 0.09090909090909093)]

I want to convert following list into dictionary.

  • If your input was a list of valid two-element tuples, you could just use the `dict` like a function. For example, `dict( [('a',0.125), ('b',0.25), ('c', 3.2) ])` results in `{'a': 0.125, 'b': 0.25, 'c': 3.2}`. Your examples are not valid strings in python, though, due to a lack of quotation marks. – qrsngky Nov 12 '22 at 04:40
  • 1
    Could you add more details to question like the expected output, your try, etc. ? – Austin Nov 12 '22 at 04:42
  • 1
    Possible duplicate of: https://stackoverflow.com/q/6522446/2745495 – Gino Mempin Nov 12 '22 at 04:43

1 Answers1

2

If you have a list of two-element tuples, then you can pass that list as an argument to dict() and it will construct the dictionary for you:

mydict = dict(list_of_tuples)
John Gordon
  • 29,573
  • 7
  • 33
  • 58