- 1

Encode string into its original uncoded form

Hi programmers. I‘m relatively new to python and I‘m doing a course in my university to learn it. I have to following problem. I have to encode the following type of strings: H-VCG EIEOS L--D- LLEI- OONN- It should be: ‚HELLO I LOVE ENCODINGS‘ I already have the following function: def decode(input_string): mylist = [ ] string = "" mylist.append(input_string[0]) for i in range(len(input_string)): if(input_string[i] == ' '): mylist.append(input_string[i+1]) for i in mylist: string += i return string THIS RETURNS ONLY THE STRING ‚HELLO‘ THE FOLLOWING STRINGS SHOULD ALSO WORK WITH THIS FUNCTION: assert_equal(decode("H-VCG EIEOS L--D- LLEI- OONN-"), 'HELLO I LOVE ENCODINGS‘) assert_equal(decode("NHRHA OA-IG BLRSE OLE-- D-AM- YEDE- -V-S- SETS-"), 'NOBODY SHALL EVER READ THIS MESSAGE') Thank you for any solutions or tips!!

9th Mar 2021, 12:43 PM
David Ruef
David Ruef - avatar
2 Respostas
9th Mar 2021, 6:30 PM
visph
visph - avatar
- 1
thank you :)
16th Mar 2021, 6:24 PM
David Ruef
David Ruef - avatar