How do I strip character 'A' from the beginning of a string if the string starts with 'A'?
"AsomethingAsomething" output should be "somethingAsomething"
"somethingAsomething" output should be "somethingAsomething"
(Using Python 3.x)
How do I strip character 'A' from the beginning of a string if the string starts with 'A'?
"AsomethingAsomething" output should be "somethingAsomething"
"somethingAsomething" output should be "somethingAsomething"
(Using Python 3.x)
Try this:
s = "AsomethingAsomethingAsomething"
s[s.find('A')+1:]
s.lstrip('A')
Combine some logic and str
methods and slice:
if some_string.startswith('A'):
some_string = some_string[1:]
Or even better, just use some_string = some_string.lstrip('A')
as proposed in the comments.
with lstrip
string = "AsomethingAsomethingAsomething"
string.lstrip('A')