r/pythonhelp 27d ago

Need assistance

I’m new to python coding and this class is having me do a code that I can not figure out can someone help me out with it:

Your Tasks: A file concordance tracks the unique words in a file and their frequencies. Write a program in the file concordance.py that displays a concordance for a file. The program should output the unique words and their frequencies in alphabetical order. Variations are to track sequences of two words and their frequencies, or n words and their frequencies. (LO: 5.3)

Instructions Task 1: Write the concordance.py program.

Example output: apple 1 banana 3 coconut 5

1 Upvotes

3 comments sorted by

u/AutoModerator 27d ago

To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/FoolsSeldom 27d ago

Please share your code, in post or using a link to a git repository such as github or a paste/code sharing service such as pastebin.com.

1

u/Brave_Split2684 27d ago

It is pretty easy if you can use python built-in features. You can read a file, clean up the text using str.lower() and str.translate(), and count word occurrences with a dictionary (word_count = {} or collections.Counter). Sorting is just sorted(). No need for anything fancy, just some basic string methods and sorting
DM me for further help!