Aug-06-2018, 07:05 AM
Hello,
I'm learning python from some online tutorials. When learning about function, there was an exercise to check "Given two integers, return True if the sum of the integers is 20 or if one of the integers is 20. If not, return False"
Before making function, i did following
but when I tried to make this in to a function
What is the need of this return since
Thanks
I'm learning python from some online tutorials. When learning about function, there was an exercise to check "Given two integers, return True if the sum of the integers is 20 or if one of the integers is 20. If not, return False"
Before making function, i did following
a = (10, 20) sum(a) == 20 or a[0] == 20 or a[1] == 20and it returns True if conditions satisfy.
but when I tried to make this in to a function
def func(a): sum(a) == 20 or a[0] == 20 or a[1] == 20when called the above function
func((10,20)). It didn't return anything. I had to put return inside the function to get True or False.
What is the need of this return since
sum(a) == 20 or a[0] == 20 or a[1] == 20this line can already return true or False on it's own???
Thanks