Created
May 21, 2021 13:39
-
-
Save Sapython/2dc08acae16a059d9ff3b99156fdd899 to your computer and use it in GitHub Desktop.
Using lambda for short and single line statements.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The lambda function | |
functionName=lambda variable: list(str(variable))[0] | |
#defining a string variable | |
a="MyLongCharacter" | |
#printing the output of our lambda function | |
print(functionName(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment