def capital_indexes(string):
indexes = []
for i, s in enumerate(string):
if s.isupper():
indexes.append(1)
return indexes
What does the s
in the for loop mean?
def capital_indexes(string):
indexes = []
for i, s in enumerate(string):
if s.isupper():
indexes.append(1)
return indexes
What does the s
in the for loop mean?
i
is the index in the string, while s
is a string of length 1 representing the letter at that index.
See documentation for enumerate