How to print only print all the values of a dictionary in python?











up vote
0
down vote

favorite
1












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










share|improve this question




















  • 1




    Possible duplicate of How to print a dictionary line by line in Python?
    – Graph Theory
    Nov 15 at 1:26















up vote
0
down vote

favorite
1












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










share|improve this question




















  • 1




    Possible duplicate of How to print a dictionary line by line in Python?
    – Graph Theory
    Nov 15 at 1:26













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












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())






share|improve this answer





















  • 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 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


















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)





share|improve this answer























  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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())






share|improve this answer





















  • 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 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















up vote
1
down vote













Python's dict has method values() that returns it. So you want to print(word_hash.values())






share|improve this answer





















  • 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 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













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())






share|improve this answer












Python's dict has method values() that returns it. So you want to print(word_hash.values())







share|improve this answer












share|improve this answer



share|improve this answer










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 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


















  • 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 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
















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












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)





share|improve this answer























  • 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















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)





share|improve this answer























  • 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













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)





share|improve this answer














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)






share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?