Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This function is to test the truthiness or falseness of an object
- # The function accept one argument
- def truthy_or_falsy(value):
- # Stating the format of the string using the formate method
- string = "The value {0} is {1}"
- if value == 0 or "":
- result = string.format(value, "falsy") # the index of value = 0 while falsy = 1
- else:
- result = string.format(value, "truthy") # the index of value = 0 while falsy = 1
- # Returning the formatted string
- return result
- # Function Declaration
- print(truthy_or_falsy(0))
- print(truthy_or_falsy(5))
- print(truthy_or_falsy("Hello"))
- print(truthy_or_falsy(""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement