Reputation: 61
This is my hash/dictionary
word_hash = {
'1': 'Awkward',
'2': 'Bagpipes',
'3': 'Banjo',
'4': 'Bungler',
'5': 'Croquet',
'6': 'Crypt',
'7': 'Dwarves',
'8': 'Fervid',
'9': 'Fishhook',
'10': 'Fjord',
'11': 'Gazebo',
'12': 'Gypsy',
'13': 'Haiku',
'14': 'Haphazard',
'15': 'Hyphen',
'16': 'Ivory',
'17': 'Jiffy',
'18': 'Jinx',
'19': 'Jukebox',
'20': 'Kayak',
'21': 'Kiosk',
'22': 'Klutz',
'23': 'Memento',
'24': 'Mystify',
'25': 'Numbskull',
'26': 'Ostracize',
'27': 'Oxygen',
'28': 'Pajama',
'29': 'Phlegm',
'30': 'Pixel',
'31': 'Polka',
'32': 'Quad',
'33': 'Quip',
'34': 'Rhythmic',
'35': 'Rogue',
'36': 'Sphinx',
'37': 'Squawk',
'38': 'Swivel',
'39': 'Toady',
'40': 'Twelfth',
'41': 'Unzip',
'43': 'Waxy',
'44': 'Wildebeest',
'45': 'Yacht',
'46': 'Zealous',
'47': 'Zigzag',
'48': 'Zippy',
'49': 'Zombie',
}
I want to make a an array of only the values and print it
Upvotes: 2
Views: 4086
Reputation: 106543
If you want the values of the dict in random order, you can use random.shuffle
:
from random import shuffle
values = list(word_hash.values())
shuffle(values)
print(values)
Upvotes: 1
Reputation: 2888
Python's dict has method values()
that returns it. So you want to print(word_hash.values())
Upvotes: 3