Question: I have the attached code and am having a problem with the next part: Count the number of characters received, and stop displaying any text

I have the attached code and am having a problem with the next part:

Count the number of characters received, and stop displaying any text after it has shown exactly 3000 characters. Since your chunk size will not divide evenly into 3000, you will need to add some logic to ensure that exactly 3000 characters (no more, and no less) are displayed.

Continue to retrieve the entire document, count the total number of characters, and display (i.e., print) the total number of characters.

I have the attached code and am having a problem with the

1 import urllib 2 import re 3 url raw_input('Enter the URL:') 4 req request (url) 5 while True: 6 try: counts dict() fhandurllib.urlopen (req) for line in fhand: words line.split) for word in words: 10 counts[word] counts.get(word,0) 1 12 13 14 15 16 17 print(counts) data - count.getlength(512) if(len (data)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!