Skip to content

Instantly share code, notes, and snippets.

@vedgar
Created November 10, 2017 01:50
Show Gist options
  • Select an option

  • Save vedgar/4d2ed55479e960f90d350d5ec75b20c0 to your computer and use it in GitHub Desktop.

Select an option

Save vedgar/4d2ed55479e960f90d350d5ec75b20c0 to your computer and use it in GitHub Desktop.
import contextlib
def second_index(text: str, symbol: str):
"""Second index of a symbol in a given text."""
with contextlib.suppress(ValueError):
manhattan = text.index(symbol)
berlin = text.index(symbol, manhattan + 1)
return berlin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment