pythonpython-3.xtypeerrorlist-comparison

How can i solve if condintion with join. How I take use if with string join


job = ''.join([i for i in job if not i.isdigit()])

Error text:

job = ''.join([i for i in job if not i.isdigit()]) TypeError: 'float' object is not iterable


Solution

  • Because isdigit is a string method, I assume you are trying to iterate over the characters in a string and remove all digits. If this is the case, you can cast job to be a string in the list comprehension:

    job = ''.join([i for i in str(job) if not i.isdigit()])