Hi, i’m having problem using python3 on my Ubuntu 16.04.3 x64 with the dict() function when i use it on my own PC it works fine but on the cloud server isn’t running well…
after sorting my dictionary with sotred() function i get this output (example):
[(1, {'car': 'red'}, 2, {'bike': 'green'}, 3, {'plane': 'white'})]
when i want it to turn the tuple to dictionary i use dict() (example):
dict([(1, {'car': 'red'}, 2, {'bike': 'green'}, 3, {'plane': 'white'})])
but when use the dict function it reorder everything randomly (example):
{2, {'bike': 'green'}, 3, {'plane': 'white'}, 1, {'car': 'red'}}
any idea why?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Python’s dict is not guaranteed to return items in the same order. Try something like this if required:
Show your test case and exact python versions for both platforms.