Filter in python3


#1

I am doing the same, practicing with Python 3 in an attempt to save some of my code findings. I did find the the list() function to convert the object to a list, but could not join it as Python 2 presents the message. Specifically, my output is:
[‘I’, ’ ', ‘a’, ‘m’, ’ ', ‘a’, ‘n’, ‘o’, ‘t’, ‘h’, ‘e’, ‘r’, ’ ', ‘s’, ‘e’, ‘c’, ‘r’, ‘e’, ‘t’, ’ ', ‘m’, ‘e’, ‘s’, ‘s’, ‘a’, ‘g’, ‘e’, ‘!’]

I don’t understand your code in the following line:

message=’’.join(message)

nor was my attempt recognized:

message = join(message)

I am using Python 3.70b3
Any help would be appreciated.


Filter function with Lambda and List in Python 3.X
#2

in python3, after you convert to list, you should be able to use .join()

the string before .join() is what is used to join the list together, for example:

print("-".join([1,2,3]))

gives 1-2-3, see how the hyphen plays it part?

join joins the list into a string, which means you need to convert to list first. This differs from python2, because in python2 range() returns a list


#3

Thanks. Got it! (add characters)