Q:

Shorter way to check if a string is not isdigit()

For the sake of learning, is there a shorter way to do:
if string.isdigit() == False :
I tried:
if !string.isdigit() : and if !(string.isdigit()) : which both didn't work.

A:

Python's "not" operand is not, not !.
Python's "logical not" operand is not, not !.

A:

In  python, you use the not keyword instead of !:
if not string.isdigit():
    do_stuff()

This is equivalent to:
if not False:
    do_stuff()

i.e:
if True:
    do_stuff()

Also, from the PEP 8 Style Guide:

Don't compare boolean values to True or False using ==.
Yes:   if greeting:
No:    if greeting == True
Worse: if greeting is True:

A:

if not my_str.isdigit()

Also, don't use string as a variable name as it is also the name of a widely used standard module.

