How can I get Python to print a specified number of words in a text file?
Hello, I have a text file, and my program needs to print a number of words the user specifies (out of 100 paragraphs). I also need to know how I can get it to print a specified number of sentences.
It doesn't really work at the moment, it only prints a random part of my text file when I press run.
words = "hello world" print(len(words.split(" ")))
as you can see that will give you 2, because there are two words