How to get the first letter index of a string after spaces in Python? [duplicate]
Is there a way to get the first letter index of a string after an n
number of spaces?
I know it is easily made with a for loop
, but for sake of simplicity, is there a cleaner way?
string_1 = " Hello" # Return 4
string_2 = " Bye" # Return 8
Method strip()
cuts spaces before the first and after the last charactes (and multiple inside like x y
.
So:
x = ' abc'
x = x.strip()
print(x) # result -> 'abc'