I have a newbie question regarding the usage of comma (,) when trying to get the key from a dictionary. I checked Python 3.7 documentation,and several other sites but couldn't find the answer.
I have a simple dictionary with one element in it:
basket = {'apple':1}
I want to get string 'apple' from it.
If I do:
k = basket.keys()
print(k)
I get
dict_keys(['apple'])
If I do:
k, = basket.keys()
print(k)
I get
apple
So why do I need the comma to get the string 'apple'?