Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
Python find first occurrence of character after index

I am trying to get the index of the first occurrence of a character that occurs in a string after a specified index. For example:

string = 'This + is + a + string'

# The 'i' in 'is' is at the 7th index, find the next occurrence of '+'
string.find_after_index(7, '+')

# Return 10, the index of the next '+' character
>>> 10
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Python is so predicable:

>>> string = 'This + is + a + string'
>>> string.find('+',7)
10

Checkout help(str.find):

find(...)
    S.find(sub[, start[, end]]) -> int

    Return the lowest index in S where substring sub is found,
    such that sub is contained within S[start:end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

Also works with str.index except that this will raise ValueError instead of -1 when the substring is not found.

over 4 years ago · Santiago Trujillo Denunciar

0

You can use:

start_index = 7
next_index = string.index('+', start_index)
over 4 years ago · Santiago Trujillo Denunciar

0

string.find('+', 7)

Read the documentation.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda