can someone help me finish this using for, while, dictionary, orthings like that, do not use enumerate ,strip, break

CountChars.py

(40 points: reading from file or URL, formatting strings, datastructures)

Begin a new file named CountChars.py by typinga comment at the top with your name (and the name of your labpartner if you work together), and the current date.

You will notice the instructions are a bit shorter this time.You are given a problem to solve, but you must figure out howto solve it yourself. Keep in mind what you have learned abouttop-down programming by stepwise refinement: break the problem intomeaningful parts; then solve each part separately. And havefun!

The problem is to write a Python3 program that reads a text fileor web page named by the user, and prints a neat table showing thecounts of all of the different characters it reads. You must alsomeet the following explicit specifications:

Since we insist that your output will exactly match the resultsof our solution (see the 3 examples below), copy the followingstring and dictionary constants and paste them to the beginning ofcountchars.py (after your header comment of course). These arealready entered for you in the start-up file calledCountChars.py.

# strings that must be used for output:prompt = “Enter filename: “titles = “char countn—- —–“itemfmt = “{0:5s}{1:10d}”totalfmt = “total{0:10d}”whiteSpace = {‘ ‘:’space’, ‘t’:’tab’, ‘n’:’nline’, ‘r’:’crtn’}

Make it so that when you run the module in IDLE, it shouldimmediately instruct the user to enter the filename, and then itshould print the table of counts in the Python shell window.Alternatively, a user can run the program directly from the commandprompt without ever starting Python or IDLE, by typing thefollowing:

-bash-4.2$ python3 CountChars.py

Execution must proceed as follows:

print( itemfmt.format(c, ccount) )print( itemfmt.format(whiteSpace[c], ccount) )print( totalfmt.format(total) )

Use the built-in function input to get the filename from theuser. Pass the string named prompt to this function.

If the filename does not begin with “http” then assume it is alocal file, and open it for reading with the built-in openfunction. Otherwise import and use the urllib.request.urlopenfunction to open the web page for reading. The program has to beable to do this automatically. Go back to the slides from class forwhen we talked about this topic.

Read all of the text in the file or web page, and count eachdifferent character in it. Ignore the case of characters (e.g.,count both ‘A’ and ‘a’ as ‘a’).

Print the string named titles. Then print thetable of characters and their counts in ASCII order, and print thetotal character count at the bottom. Hint: There are 128 charactersin the ASCII code, starting from 0 and ending at 127.

Use the string named itemfmt to print eachinterior row of the table in the proper format. For example, if cis a character, and ccount is its count (which should be recordedin the dictionary you created), then print that row of the table asfollows:

If the character being printed is one of the white spacecharacters in the dictionary named whitespace,then print its description instead of the character itself. Forexample:

Use the string named totalfmt to properly printthe total character count. If this count is namedtotal, for example:

Fully test your program. Here are sample input files and webpages, and the associated results from our solution. Make sure thatyour results exactly match these results.Also realize that the graders will probably test other inputstoo.

mport urllib.request

# This function reads all the lines, reads all the characters,makes a dictionary
def MakeD(xfile):
# STUDENTS: FINISH THIS PART

def main():
# strings that must be used for output:
prompt = “Enter filename: “
titles = “char countn—- —–“
itemfmt = “{0:5s}{1:10d}”
totalfmt = “total{0:10d}”
whiteSpace = {‘ ‘:’space’, ‘t’:’tab’, ‘n’:’nline’,’r’:’crtn’}

# Get file name and see if you need to use open or urlopen
# Call the function MakeD as appropriate
# STUDENTS: FINISH THIS PART

# Print out contents of dictionary
print(titles)
# STUDENTS: FINISH THIS PART
# Hint: go thru all 128 ASCII characters and see if they’re in thedictionary
# Follow instructions closely

if __name__ == “__main__”:
main()

codes abvoe are what have been provided

thanks so much!