I have a string like
\"xdtwkeltjwlkejt7wthwk89lk\"
how can I get the index of the first digit in the string?
Thought I'd toss my method on the pile. I'll do just about anything to avoid regex.
sequence = 'xdtwkeltjwlkejt7wthwk89lk'
i = [x.isdigit() for x in sequence].index(True)
To explain what's going on here:
[x.isdigit() for x in sequence]
is going to translate the string into an array of booleans representing whether each character is a digit or not[...].index(True)
returns the first index value that True
is found in.