Turn on thread page Beta

Can someone please help me with this code watch

    • Thread Starter
    Offline

    0
    ReputationRep:
    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(" ")
    print(sentence)
    #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]:
    print(x)

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

    #T 3

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

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

    Thank You
    • TSR Support Team
    Online

    21
    ReputationRep:
    TSR Support Team
    JTran38 Have you managed task 3 yet? (Sorry I know how much you love computing but I'm really not good with python)
    • Community Assistant
    • Political Ambassador
    Offline

    20
    ReputationRep:
    Community Assistant
    Political Ambassador
    (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.
    • TSR Support Team
    Online

    21
    ReputationRep:
    TSR Support Team
    (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
    Offline

    0
    ReputationRep:
    is this task 2?
    • TSR Support Team
    Online

    21
    ReputationRep:
    TSR Support Team
    (Original post by Yasha Syed295)
    is this task 2?
    I'm not doing this task, nor do I have a copy of it on me, but I believe the first part of the code is task 2, while the second part is task 3.
    CoffeeAndPolitics may be able to help to identify the tasks?
    • Community Assistant
    • Political Ambassador
    Offline

    20
    ReputationRep:
    Community Assistant
    Political Ambassador
    (Original post by Yasha Syed295)
    is this task 2?
    If you kindly PM me, I'll be happy to have a look and try to help you out - Obviously, I can't give you my entire code as that would be plagiarism.

    Thanks Lemur14 for tagging me.
    Offline

    0
    ReputationRep:
    can you please indent this code properly. Please as i can't get it to work
 
 
 
Poll
Do you think parents should charge rent?
Useful resources

Study tools

Rosette

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.

Creating

Make study resources

Create all the resources you need to get the grades.

Planner

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.

Papers

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

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