Can I store only numbers in a Python dictionary or also words and values?

Can I also save values ​​in a dictionary in Python? Can I then call them up like that? I think it's like a dictionary attack, the program basically runs through all the keywords until the right one is found and then outputs a word based on PEI compatibility. So you could, for example, play a guessing game where you can have Python guess the word using the dictionary?

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
4 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jo135
9 months ago

Please use set marks and halfway correct spelling. Your question is very difficult to read.

In a dictionary Values any type. Also mixed.

The Key but have to be “hashable”. In a very simple way, this excludes all types that change in themselves, such as lists or dictionarys. Strings and numbers are not a problem.

And yes, you can pass through all keys (and values).

for key, value in my_dict.items():
   print(key, value)
jo135
9 months ago
Reply to  gutefrage108

I’m sorry, I don’t understand what you’re asking. Please try this again with previously sorted thoughts in German.