Python Programming - Lambda Functions - Discussion

Discussion Forum : Lambda Functions - General Questions (Q.No. 61)
61.
What does the following lambda function accomplish?
lambda x: x.split()[0] if isinstance(x, str) else None
Extracts the first word of a string and returns None for non-string values.
Converts a string to uppercase and returns None for non-string values.
Joins all words in a string and returns None for non-string values.
Returns the length of a string and None for non-string values.
Answer: Option
Explanation:
The lambda function extracts the first word of a string and returns None for non-string values.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.