I try to understand, in this code, why python print the letter "w"? (I work with python 2.7.8):
LetterNum = 1
for Letter in 'Howdy!':
if Letter == 'w':
pass
print 'Encountered w, not processed.'
print ('Letter', LetterNum, 'is', Letter)
LetterNum+= 1
I get this result:
>>>
('Letter', 1, 'is', 'H')
('Letter', 2, 'is', 'o')
Encountered w, not processed.
('Letter', 3, 'is', 'w')
('Letter', 4, 'is', 'd')
('Letter', 5, 'is', 'y')
('Letter', 6, 'is', '!')
While I thought I should get this result:
>>>
('Letter', 1, 'is', 'H')
('Letter', 2, 'is', 'o')
Encountered w, not processed.
('Letter', 4, 'is', 'd')
('Letter', 5, 'is', 'y')
('Letter', 6, 'is', '!')
>>>
for LetterNum, Letter in enumerate('Howdy!'):Note though that this is zero-indexed by default.