-4

I have 2 dictionaries in Python the user is asked to press a key to show a random key from the 2 dictionaries How can I do that?

Thank you

Samid Log
  • 21
  • 1
  • Does this answer your question? [How to get a random value from dictionary in python](https://stackoverflow.com/questions/4859292/how-to-get-a-random-value-from-dictionary-in-python) – Ahmad Feb 18 '20 at 11:09

1 Answers1

1

You can use random.choice:

>>> import random
>>> random.choice([*dict1.keys(), *dict2.keys()])
Vicrobot
  • 3,795
  • 1
  • 17
  • 31
  • Hi, I have tried it and it does not select a key from one of the two dictionaries, but it selects one a random hall disctionary – Samid Log Feb 18 '20 at 11:48