Shuffling specific values in a dictionary (Python 3.5)
<p>I am writing a murder mystery--a lot like Clue. I am using dictionaries to store all my info. My question: is there a way to shuffle dictionary values which pull from a set range of integers? I want every game to shuffle certain values within the dictionaries when starting a new game. Right now I'm focused on character placement...I'm trying to figure out the best way to shuffle character locations once each game (locations[current_room]["char"]. Once I understand how to do this, I want to apply this to a bunch of other aspects of the game--with the idea of creating a brand new mystery to solve each game. Any suggestions welcome!</p>

<p><strong>EDIT</strong>
Thanks for the answers! I am not trying to randomize my entire dictionary, just change the values of certain keys each game.  I think I might need to solve this problem another way.  I will update this post when I get things working.</p>

<p><strong>FINAL EDIT</strong> I'm changing the value of specific keys I want "shuffled" by editing the dictionary.  locations[1]["char"] = random.choice([0,1,2])  and then changing the other values based on a series of IF statements from the result in the random.choice.  Thanks again for the help.</p>

<pre><code>locations = {
1: {"name": "bedroom",
    "msg": "There is a painting on the wall. \nThe window looks out into the garden.",
    "char": 2,
    "item": "matches",
    "west": 2},
2: {"name": "living room",
    "msg" : "The room is freezing cold. The fireplace is empty.",
    "char": 1,
    "Item": "firewood",
    "east": 1},
}

characters = {
1: {"name": "doctor crichton",
    "msg": "A tall, handsome archeologist home from a dig in Africa."},
2: {"name": "the widow",
    "msg": "An beautiful woman with a deep air of sadness."},
}   
current_room = 1

current_char = locations[current_room]["char"]

def status():
    """updates player on info on current room"""
    print("You are in the " + locations[current_room]["name"])
    char_status()

def char_status():
    """compiles character infomation in current room"""
    if current_char &gt; 0:
        char_room_info()
    else:
        print("\nThis room is empty.")

def char_room_info():
    """NPC behavior in each room"""
    print(characters[current_char]["name"].title() + " is in the room with you.")

status()
</code></pre>

<p>Python dictionaries are unordered, so I dont see why you woulf want to "shuffle" them. If you want to pick random strings inside the dict, maybe you could use a list to wrap this dictionary for simplicity sake.</p>

<p>Like so:</p>

<p><code>Locations = [ {"name": "bedroom...}, {"name": "livingroom"...},...]</code></p>

<p>I think you get the point. So now to access them:</p>

<p><code>Locations[random.rand]["name"]</code></p>

<p>Also you could use this:</p>

<pre><code>random.choice(locations.keys()) 
</code></pre>

<p>Which is far easier.</p>

python dictionary text adventure