Answers for "Python program that takes a text file as input and returns the number of words of a given text file"

0

Python program that takes a text file as input and returns the number of words of a given text file

with open('file1.txt','r+') as f:
	lines=f.read()
	words=lines.split()
	print(len(words))
Posted by: Guest on December-03-2020
0

Python program that takes a text file as input and returns the number of words of a given text file

with open('file1.txt','r+') as f:
	numw=0
	for line in f:
		words= line.split()
		print(words)
		numw += len(words)
	print(numw)
Posted by: Guest on December-03-2020

Code answers related to "Python program that takes a text file as input and returns the number of words of a given text file"

Python Answers by Framework

Browse Popular Code Answers by Language