How to test characters of a string
2QdxY4RzWzUUiLuE at potatochowder.com
2QdxY4RzWzUUiLuE at potatochowder.com
Tue Jun 7 16:08:10 EDT 2022
On 2022-06-07 at 21:35:43 +0200,
Dave <dave at looktowindward.com> wrote:
> I’m new to Python and have a simple problem that I can’t seem to find
> the answer.
> I want to test the first two characters of a string to check if the
> are numeric (00 to 99) and if so remove the fist three chars from the
> string.
> Example: if “05 Trinket” I want “Trinket”, but “Trinket” I still want
> “Trinket”. I can’t for the life of work out how to do it in Python?
How would you do it without Python?
Given that if the string is called x, then x[y] is the y'th character
(where what you would call "the first character," Python calls "the
zeroth character"), describe the steps you would take *as a person* (or
in some other programming language, if you know one) to carry out this
task.
Translating that algorithm to Python is the next step. Perhaps
https://docs.python.org/3/library/string.html can help.
More information about the Python-list
mailing list