[SOLVED] How to differentiate between a number and a letter or sign?

Issue

If I have a digit within a string I can just do:

x = "2"
x.isdigit()

and I get True. But when I do this:

isinstance(x, str)

By my understanding this also results in True.

My question is now how can I tell if it is a character or a number?

Solution

Use isalpha() for this:

x = "2"
x.isalpha()

Returns False

Answered By – JANO

Answer Checked By – Cary Denson (BugsFixing Admin)

Leave a Reply

Your email address will not be published.