I need to code a program that input will be any random string and the the output will include processes, unprocessed string.
EX:
Input String : XYZZXXYYXYZZXYZ
Unique Prefixes :
Encode List : [(0, 'X'), (0, 'Y'), (0, 'Z'), (3, 'X'), (1, 'Y'), (2, 'X'), (2, 'Z'), (4, 'Y'), (3, '')]
Encoded Binary String : 00101100000101100100010110101101011000001010110010100101100000100101101001000101100100011
Decoded String : XYZZXXYYXYZZXYZ
If anyone can help me with this. I am very thankful and appriciated.

With the encoded text, I would go with dictionary rather than tuples.
As for the prefix stuff, try split.('sting')
for the unique prefixes take a look at itertools
More spacificaly itertools.permutation(string)

How do you get from here
Input String : XYZZXXYYXYZZXYZ

to here (and what happened to the final "Z")
Unique Prefixes :

to here [and is (3,'') the final Z]
Encode List : [(0, 'X'), (0, 'Y'), (0, 'Z'), (3, 'X'), (1, 'Y'), (2, 'X'), (2, 'Z'), (4, 'Y'), (3, '')]

and especially to here (using 9 bits per byte at least some of the time)
Encoded Binary String :
001011000 = "X"
001011001 = "Y"
0
001011010 = "Z"
?????
1101011000001010110010100101100000100101101001000101100100011
Decoded String : XYZZXXYYXYZZXYZ

Sorry, this is not my example. It comes from another person, that why I am confuse also. I just dont get how can we can split a random string into part like compression and decompression EX:'ABCD' into 'A', 'AB', 'ABC', 'ABCD'

Sorry, this is not my example. It comes from another person, that why I am confuse also. I just dont get how can we can split a random string into part like compression and decompression EX:'ABCD' into 'A', 'AB', 'ABC', 'ABCD'

The example suspiciously resembles the LZ compression (at least the prefixes and the encode list make certain sense). Please make sure that that another person supplied you with correct figures. Also it would be helpful to know what alphabet is used in the example (the example is almost correct for an alphabet of just X, Y an Z).

Again, sorry the stupid mess up at the beginning and even the second one was not the right one. Simple that, I just need to figure how to create a list from a random string. but the hard way for me is it is require that if the character is not list before it must be list later. the clearer example is that with the string ABABCABABAC we must create a list that I am able to figure that I must use list() to create the first list which separate all character but I am stuck right at the step becuse I dont know which loop I must use to solve this (I tried for-loop, while-loop, if-elif-else). So, if anyone could give me at least a hint how to solve this problem. I am very appriciate.

How do you get from here
Input String : XYZZXXYYXYZZXYZ

to here (and what happened to the final "Z")
Unique Prefixes :

to here [and is (3,'') the final Z]
Encode List : [(0, 'X'), (0, 'Y'), (0, 'Z'), (3, 'X'), (1, 'Y'), (2, 'X'), (2, 'Z'), (4, 'Y'), (3, '')]

and especially to here (using 9 bits per byte at least some of the time)
Encoded Binary String :
001011000 = "X"
001011001 = "Y"
0
001011010 = "Z"
?????
1101011000001010110010100101100000100101101001000101100100011
Decoded String : XYZZXXYYXYZZXYZ

I final Z is not repeat due to it is the last character of the string and it is already listed in the first 4 character. The same with the second and third line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.