How to print only print all the values of a dictionary in python?
up vote
0
down vote
favorite
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
python dictionary
add a comment |
up vote
0
down vote
favorite
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
python dictionary
1
Possible duplicate of How to print a dictionary line by line in Python?
– Graph Theory
Nov 15 at 1:26
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
python dictionary
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
python dictionary
python dictionary
edited Nov 15 at 0:16
blhsing
27.8k41335
27.8k41335
asked Nov 15 at 0:14
Ishani Chakravorty
11
11
1
Possible duplicate of How to print a dictionary line by line in Python?
– Graph Theory
Nov 15 at 1:26
add a comment |
1
Possible duplicate of How to print a dictionary line by line in Python?
– Graph Theory
Nov 15 at 1:26
1
1
Possible duplicate of How to print a dictionary line by line in Python?
– Graph Theory
Nov 15 at 1:26
Possible duplicate of How to print a dictionary line by line in Python?
– Graph Theory
Nov 15 at 1:26
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Python's dict has method values()
that returns it. So you want to print(word_hash.values())
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
import random module and thenrandom.sample(word_hash.values(), 15)
or any your number.
– sashaaero
Nov 15 at 0:25
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
|
show 1 more comment
up vote
0
down vote
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)
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Python's dict has method values()
that returns it. So you want to print(word_hash.values())
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
import random module and thenrandom.sample(word_hash.values(), 15)
or any your number.
– sashaaero
Nov 15 at 0:25
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
|
show 1 more comment
up vote
1
down vote
Python's dict has method values()
that returns it. So you want to print(word_hash.values())
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
import random module and thenrandom.sample(word_hash.values(), 15)
or any your number.
– sashaaero
Nov 15 at 0:25
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
|
show 1 more comment
up vote
1
down vote
up vote
1
down vote
Python's dict has method values()
that returns it. So you want to print(word_hash.values())
Python's dict has method values()
that returns it. So you want to print(word_hash.values())
answered Nov 15 at 0:17
sashaaero
8181620
8181620
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
import random module and thenrandom.sample(word_hash.values(), 15)
or any your number.
– sashaaero
Nov 15 at 0:25
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
|
show 1 more comment
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
import random module and thenrandom.sample(word_hash.values(), 15)
or any your number.
– sashaaero
Nov 15 at 0:25
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
thank you! and how would i randomize it?
– Ishani Chakravorty
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
What do you mean by randomize? You want to pick n random values?
– sashaaero
Nov 15 at 0:20
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
yes i want it to randomize it that way
– Ishani Chakravorty
Nov 15 at 0:23
import random module and then
random.sample(word_hash.values(), 15)
or any your number.– sashaaero
Nov 15 at 0:25
import random module and then
random.sample(word_hash.values(), 15)
or any your number.– sashaaero
Nov 15 at 0:25
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
what does 15 do?
– Ishani Chakravorty
Nov 15 at 0:30
|
show 1 more comment
up vote
0
down vote
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)
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
add a comment |
up vote
0
down vote
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)
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
add a comment |
up vote
0
down vote
up vote
0
down vote
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)
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)
edited Nov 15 at 0:51
answered Nov 15 at 0:20
blhsing
27.8k41335
27.8k41335
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
add a comment |
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
afaik he wants randomness :/
– Joran Beasley
Nov 15 at 0:42
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
yes but it is not working
– Ishani Chakravorty
Nov 15 at 0:45
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
@IshaniChakravorty I've updated my answer with how you can randomize the values of the dict then.
– blhsing
Nov 15 at 0:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310681%2fhow-to-print-only-print-all-the-values-of-a-dictionary-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Possible duplicate of How to print a dictionary line by line in Python?
– Graph Theory
Nov 15 at 1:26