So I created a dictionary for setting difficulty level on a little game.
diff_dict = {'easy':0.2, 'medium':0.1, 'hard':0.05} # difficulty level dict
Keys are going to be the difficulty names and the values some ratios that i would use to compute the difficulty.
So I was trying to figure out how to print only the keys to the user:
print('\nHere are the 3 possible choices: ',diff_dict.keys())
this would print as:
Here are the 3 possible choices: dict_keys(['hard', 'easy', 'medium'])
Obviously I don't want to have the dictionary name displayed so I continued to search and I did find a solution which works:
diff_keys = diff_dict.keys()
print ('\nHere are the 3 possible choices: ',list(diff_keys))
But I still want to know if there are other methods to achieve this, then why and so on. So here I go with the Qs:
Can I achieve the same result without crating a new element, such as diff_keys?
Why does
diff_dict.keys
display the dict. name? Am I doing something wrong?On a side note, how can I print keys or other elements like lists, tuples, etc without the string quotes (')?
same as #3 above but the brackets ([ ])
thanks and cheerio :-)