Skip to content

Instantly share code, notes, and snippets.

@Sapython
Created May 21, 2021 13:39
Show Gist options
  • Save Sapython/2dc08acae16a059d9ff3b99156fdd899 to your computer and use it in GitHub Desktop.
Save Sapython/2dc08acae16a059d9ff3b99156fdd899 to your computer and use it in GitHub Desktop.
Using lambda for short and single line statements.
#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