python - Why does it say this--> TypeError: 'bool' object is not iterable -
content text file
tokens = content.split() topics = [e (n, x) in enumerate(tokens) (n2, x2) in enumerate(tokens) (i, e) in enumerate(tokens) if any(x2.isdigit()) if '.' in x if re.findall('\d+', x) if n < < n2] i dont understand how iterating through bool , there more concise , faster way of doing list comprehension?
your issue comes - any(x2.isdigit()) , guessing x2 string, x2.isdigit() returns bool , cannot use any() function on it.
try using without any() function check if x2 number -
if x2.isdigit() if want check whether x2 has digit in or not, can try -
if any(i.isdigit() in x2) though not know trying do, cannot check if other logic or not.
any() function used on iterable (lists or generator expression, etc) , check if of them true.
Comments
Post a Comment