Question: PERFORM USING PYTHON! Write a program that reads in a Python source code file and counts the occurrence of each identifier (variables, class, and method
PERFORM USING PYTHON!

Write a program that reads in a Python source code file and counts the occurrence of each identifier (variables, class, and method names) in the file using a dictionary. Another dictionary is used to positions of identifiers with a list in the file. Your program should prompt the user to enter the Python source code filename and then construct these two dictionaries. After reading the entire file, the program should display the contents two dictionaries. Ex: ab = de # starts at 0 x=x + ab +1 #starts at 8 # starts at 22 y = ab dictCounts: {'ab': 3, 'de': 1, 'x': 3, 'y': 1} dictPositions: {'ab': [0, 16, 26], 'de': [5], 'x': [8, 12], 'y': [22]}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
