-4
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?

Wondercricket
  • 7,651
  • 2
  • 39
  • 58
  • 1
    It doesn't have any special meaning. It's just a variable. You can call it whatever you want. Do you mean to ask what [enumerate](https://docs.python.org/3/library/functions.html#enumerate) does in that loop? – Brian61354270 Sep 03 '21 at 19:44
  • 1
    How about [reading the docs](https://docs.python.org/3/library/functions.html#enumerate)? "...returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over iterable" – Cory Kramer Sep 03 '21 at 19:44

1 Answers1

0

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

Flyrom
  • 84
  • 1
  • 8