How to test characters of a string
De ongekruisigde
ongekruisigde at news.eternal-september.org
Tue Jun 7 15:58:06 EDT 2022
On 2022-06-07, Dave <dave at looktowindward.com> wrote:
> Hi,
>
> 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?
s[3:] if s[0:2].isdigit() else s
> All the Best
> Dave
>
--
<StevenK> You're rewriting parts of Quake in *Python*?
<knghtbrd> MUAHAHAHA
More information about the Python-list
mailing list