Ad
  • Default User Avatar

    Firstly remove pass. it's only used when we need a statement, but don't want to put code, like for Java, we'd have to put some filler command like "System.out.print("");" in that function as it can't be empty.

    Moving onto the question, since you're already reducing the length you need to act on ( for example, if your string is 'hello', then "len(string)-4" will imply, you'll just read 'h' ), so you don't need to use if-else.
    Finally, you need to RETURN the encoded sting instead of printing it, so you'll have to convert that list back to a string.

    I used the following code to do that:

    codedstring = "".join(map(str, cc)

    return codedstring

    Also, in your function body use another variable name like "cc_new" instead of "cc" but that's just my opinion.( cc_new = list(cc) )

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution