Python-17:Advanced Topics in Python


#1

Hello Friends,I need explanation for


https://www.codecademy.com/courses/python-beginner-en-KAgt5/4/4?curriculum_id=4f89dab3d788890003000096

Although ,I solved the challenge ,I still can't wrap my head with this "Lambda" thing.I don't get how the computer understands my code


garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"

message=filter(lambda i:i!="X",garbled)
print message


Can anybody explain me how does,I am trying to solve this problem by
usual function style.Following is my code:

def deCrypt(str):
    message=""
    for i in str:
        if i!="X":
            return message+i
    return message        
    
print deCrypt(garbled)

It is not working .Can somebody help me ?.Thanks in advance.


#2

a function ends the moment return keyword is reached, you want to update message here, not return it


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.