Click here to Skip to main content
15,850,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a dict like this
{'b50a': '02246,'}

I would like to convert it to a string but change the position.
My expectation result like this:


Anyone can help me please. I really appreciated. Thanks

What I have tried:

result = ":".join(DictValue)
Updated 10-Mar-21 23:42pm

So you want to print the value followed by the key.

Ways to do that can differ whether you are using Python 2 or 3

Have a look at solutions to this post How do I print the key-value pairs of a dictionary in python[^]

For i in DictValue
    print(i, DictValue[i])
If you want to get the concatenated string into another variable then use the technique I showed you in your previous question.

I really do recommend buying a decent book or using a tutorial and working your way through it. Posting questions here is not a good way to learn the language (although answering them is helping me on that journey!)
Share this answer
I gave you the link to the tutorial at How to convert string to array with Python?[^]. It really is time you made use of it and actually learned the language you are trying to use. This is the sort of basic question that is explained very early in the tutorial.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900