1

I want to use the optional parameters of the count method.

I don't know if the problem is a syntax problem.

str.count(sub[, start[, end]]) Return the number of non-overlapping occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation.

I've tried: 1.

cadena = "supercalifragilisticoespialidoso"
print(cadena.count("l",[0,15]))

2.

cadena = "supercalifragilisticoespialidoso"
print(cadena.count("l",[int(0),int(15)]))

3.

cadena = "supercalifragilisticoespialidoso"
print(cadena.count("l",[0,[15]]))

Always, the error seems to be the same:

TypeError: slice indices must be integers or None or have an __index__ method
Austin
  • 25,759
  • 4
  • 25
  • 48

0 Answers0