Hey! Sign in to get help with your study questionsNew here? Join for free to post

Can someone please help me with this code

Announcements Posted on
Would YOU be put off a uni with a high crime rate? First 50 to have their say get a £5 Amazon voucher! 27-10-2016
    • Thread Starter

    I have done some of the code but need help with the rest of it.

    Coding Criteria:
    This programme needs to be able to compress a text file with several
    sentences, including punctuation.
    File must be compressed into a list of words and list of positions.
    Code should be able to take a compressed file and recreate the full text of
    the original text.

    This is as much as i have been able to do:

    #Compresses T2
    def compress():

    #Input stored as a variable.
    sentence = input("Please enter a sentence")
    #Sentence is split up into individual words.
    sentence = sentence.split(" ")
    #If there are any duplicates in the list they are removed.
    sent_list = list(set(sentence))
    #The new list is put back into the original order
    sent_list2 = sorted((sent_list),key = sent_list.index)
    print("These are the word that occur in your list:",sent_list2)

    #This recreates the code from the positions of the words in the list.
    for i in range (len(sent_list)):
    for x in range (len(sent_list2)):
    if sent_list[i] == sent_list2 [x]:

    #Writes code to a file
    file_ = open("sent_list.txt", "w")

    #T 3

    #Uncompreses T2
    def uncompress():
    file1 = open("sent_list.txt","r")
    print (file1.read())
    #Menu is created so user can compress or decompress the file.
    menu=input("what would you like to do: 1: Compress 2: Decompress")
    if menu==1:
    elif menu==2:

    Some one please show me what to do next or give me some advice.

    Thank You

    JTran38 Have you managed task 3 yet? (Sorry I know how much you love computing but I'm really not good with python)

    (Original post by Lemur14)
    JTran38 Have you managed task 3 yet? (Sorry I know how much you love computing but I'm really not good with python)
    Thanks for tagging me in this. If the person can DM me, I'll have a look.

    (Original post by JTran38)
    Thanks for tagging me in this. If the person can DM me, I'll have a look.
    great I'm sure theprogrammer786 will take you up on that. Skype me if you need help, but as I say, python and me do not get on
Write a reply…


Submit reply


Thanks for posting! You just need to create an account in order to submit the post
  1. this can't be left blank
    that username has been taken, please choose another Forgotten your password?
  2. this can't be left blank
    this email is already registered. Forgotten your password?
  3. this can't be left blank

    6 characters or longer with both numbers and letters is safer

  4. this can't be left empty
    your full birthday is required
  1. Oops, you need to agree to our Ts&Cs to register
  2. Slide to join now Processing…

Updated: July 14, 2016
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

I want...
Useful resources

Study tools


Essay expert

Learn to write like a pro with our ultimate essay guide.

Thinking about uni already?

Thinking about uni already?

See where you can apply with our uni match tool

Student chat

Ask a question

Chat to other GCSE students and get your study questions answered.


Make study resources

Create all the resources you need to get the grades.


Create your own Study Plan

Organise all your homework and exams so you never miss another deadline.

Resources by subject

From flashcards to mind maps; there's everything you need for all of your GCSE subjects.


Find past papers

100s of GCSE past papers for all your subjects at your fingertips.

Help out other students

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.