-1
def process_text(title):
nopunc = [char for char in text if char not in string.punctuation]
nopunc = ''.join(nopunc)
clean_texts = [word for word in nopunc.split() if word.lower() not in stopwords.words('english']
return clean_texts

  File "<ipython-input-34-7ad84bab21d6>", line 3
    nopunc = [char for char in text if char not in string.punctuation]
         ^
IndentationError: expected an indented block

I am new to machine learning and can someone tell me what is causing this problem

jtsw1990
  • 170
  • 1
  • 10
  • 2
    python uses indentation to create blocks of code. all the coide under def should be 4 spaces more to the right – B. Go Feb 17 '20 at 12:54
  • Does this answer your question? [Python 2.7 IndentationError](https://stackoverflow.com/questions/38405772/python-2-7-indentationerror) – Maximouse Feb 17 '20 at 14:51
  • Does this answer your question? [I'm getting an IndentationError. How do I fix it?](https://stackoverflow.com/questions/45621722/im-getting-an-indentationerror-how-do-i-fix-it) – Gino Mempin Apr 24 '21 at 00:18

1 Answers1

0

Try this. Indentation is a way of telling the Python interpreter that a series of statements belong to a particular block of code, much like how other languages use {}.

def process_text(title):

    nopunc = [char for char in text if char not in string.punctuation]
    nopunc = ''.join(nopunc)
    clean_texts = [word for word in nopunc.split() if word.lower() not in 
        stopwords.words('english']

    return clean_texts
jtsw1990
  • 170
  • 1
  • 10