Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help. This function keeps repeating this print-out \"There are 7 four lette

ID: 3533290 • Letter: N

Question

Need help. This function keeps repeating this print-out "There are 7 four letter words in the file 0". Can it be fix to print out just my four letter words in the 'words.txt'. I think also it is not picking-up my CSV file and print-out the words in it. Thanks ahead for the help, if can.

words = "words.csv"

def problem5(words):

file = open(words)

line = file.readline()

reader = Csv.reader(words)

ans = 0

for i in file.readline():

words = i.split(',')

for j in words:

if len(j) == 4:

ans +=1

print ("There are 7 four letter words in the file",ans)

problem5(words)

Explanation / Answer

words = "words.csv"

def problem5(words):

file = open(words)

line = file.readline()

reader = Csv.reader(words)

ans = 0

w=[]

for i in file.readline():

words = i.split(',')

for j in words:

if len(j) == 4:

ans +=1

w=w+[j]

print ("There are %d four letter words in the file ",ans)

print (" the words are ")

for x in w:

print (x)

problem5(words)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote