Nov-27-2017, 08:19 AM
I python documentation I found the below code and it's output -
>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
... print(i, a[i])
...
0 Mary
1 had
2 a
3 little
4 lamb
But in while I am practising in python 3.6 and going through the same code I am getting some different format output. The code along with the output is given below -
>>> word
['dog', 'window', 'cat', 'window']
>>> for i in range(len(word)):
... print(i,word[i])
...
(0, 'dog')
(1, 'window')
(2, 'cat')
(3, 'window')
Please ensure me which one should I follow, the documented one or the output that I am getting because it is of some different formatted.
>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
... print(i, a[i])
...
0 Mary
1 had
2 a
3 little
4 lamb
But in while I am practising in python 3.6 and going through the same code I am getting some different format output. The code along with the output is given below -
>>> word
['dog', 'window', 'cat', 'window']
>>> for i in range(len(word)):
... print(i,word[i])
...
(0, 'dog')
(1, 'window')
(2, 'cat')
(3, 'window')
Please ensure me which one should I follow, the documented one or the output that I am getting because it is of some different formatted.