Hack Forums
[Python] Get dict out of list - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Get dict out of list (/showthread.php?tid=5769924)



Get dict out of list - lamadamadoo - Dec 17, 2017

Hey guys, probably a noob question but I have a list wich contains a dict; [{"mood":"fustrated","reason":"shit ain't working"}]
Like that, how do I get it to be just a dict? {"mood":"fustrated","reason":"shit ain't working"}

Thanks in advance!


RE: Get dict out of list - TheMarkMan - Dec 17, 2017

You'd take the 0 index of that list. That would be the dictionary itself


RE: Get dict out of list - lamadamadoo - Dec 17, 2017

I was also thinking that, I was fustrated why it didn't work.. Later I saw it was a string representation of a dict in a list   🤮
It's solved now, thanks.