How do I make a sentence with dictionary values?

Asked 2 years ago, Updated 2 years ago, 16 views

dic = {'H':1, 'e':1, 'l':3, 'o':2, '':1, 'w':1, 'r':1, 'd':1}

I'm trying to make it into Hello world. I don't know what to do because I'm trying to make it using dictionary only. Please give me some advice

python

2022-09-21 20:04

1 Answers

Dictionary is an unordered data structure unlike list and tuple.

Therefore, there is no way to always create "Hello world" through dic above.

It may be possible to use an ordered dictionary with the collection module , but it cannot be done with a regular dictionary.

Why are you trying to make a string into a dictionary??


2022-09-21 20:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.