Your issue comes from - any(x2.isdigit())
, I am guessing x2
is a string, so x2.isdigit()
returns a bool
, you cannot use any()
function on it.
Try using without the any()
function to check if x2 is a number -
if x2.isdigit()
If what you want to check is whether x2
has a digit in it or not, you can try -
if any(i.isdigit() for i in x2)
Though I do not know what you are trying to do, so cannot check if the other logic is good or not.
any() function is used on a iterable (lists or generator expression, etc) , to check if any of them is True.