Hi All,
My python version is 3.6.7
I need help to understand this piece of code?
rainbow ={"Green": "G", "Red": "R", "Blue": "B"}
# ennumerate with index, and key value
fori, (key, value) inenumerate(rainbow.items()):
print(i, key, value)
This gives a output as always:-
0 Green G
1 Red R
2 Blu
Thanks Alan and Mats for the explanation.
On 05/07/19 19:57, Mats Wichmann wrote:
On 7/4/19 3:53 PM, Alan Gauld via Tutor wrote:
Does this means that the Dict is ordered? or it is implementation dependent?
Neither, it means the items in a list always have indexes
starting at zero.
By pure co
Hi All,
Need one help in understanding generator expression/comprehensions.
This is my sample code.
# This code creates a generator and not a tuple comprehensions.
my_square =(num *num fornum inrange(11))
print(my_square) # at 0x7f3c838c0ca8>
# We can iterate over the square generator like thi