Python abilities on strings the Encoding scheme is given below:
  
  Don't replace the characters in the even places. Replace the characters in the odd places by their place numbers . and if they exceed 'z', then again they will start from 'a'.
  
  example: for a message "hello" would be "ieolt" and for message "maya" would be "naba"
  
  how many lines of code [minimum] do we have to write in order to encode a lengthy string in python in the above format.?


mycode is given below:

def encode(msg):
    encoded_message = ""
    letters = "abcdefghijklmnopqrstuvwxyz"
    index_of_msg = 0
    for char in msg.lower():
        if char.isalpha():
            if index_of_msg%2 == 0 :          
                encoded_message += letters[((letters.rfind(char) )+ (index_of_msg+1))%26]  # changed msg.rfind(char) to index_of_msg
            else:
                encoded_message += char
        else:
            encoded_message += char
        index_of_msg +=1
    return encoded_message
Here's a one liner for you (since the question asks for the minimum number of lines):

encode = lambda s: "".join([(c if (i+1) % 2 == 0 else chr(ord('a') + (ord(c) - ord('a') + i + 1) % 26)) for i, c in enumerate(s)])