Python: for loops txt text without entering data

is writing a word cloud at the beginning of python, but there is still nothing in wordcount at present. Is there something wrong with the circular input?
where stopwords is a content set containing commonly used non-essential words

>>> import wordcloud
>>> import collections
>>> file=open("/Users/Downloads/word_cloud/98-0.txt")
>>> wordcount={}
>>> stopwords = set(line.strip() for line in open("/Users/Downloads/word_cloud/stopwords"))
>>> for word in file.read().lower().split():
    word = word.replace(".","")
    word = word.replace(",","")
    word = word.replace("\"","")
    word = word.replace(""","")
    if word not in stopwords:
        if word not in wordcount:
            wordcount[word] = 1
        else:
            wordcount[word] += 1
>>> wordcount
{}

topic description

sources of topics and their own ideas

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Mar.24,2022

your code executes normally on my machine. You have a problem. I guess it's indentation. Try indenting the sentence after for.

Menu