Problem: Finding the Odd numbers within given range(inclusive). l
= left range, r
= right range. For example:
Input:
l=2
r=5
Expected Output:
3
5
As I have already done this program in one method shown in below,
def findOddNumber(l,r):
for num in range(l,r):
if(num%2!=0):
print(num)
l=2
r=5
res=[]
findOddNumber(l,r)
Instead of printing in user defined function like above, I'm expecting to return the values to calling function, I have tried like this:
def findOddNumber(l,r):
for num in range(l,r):
if(num%2!=0):
return num
l=2
r=5
res=findOddNumber(l,r)
print(res)
Output:
3
Expected output:
3
5