-4

It seems that return is not working:

def hello(x,y):
return x
return y

I can't seem to return y why is this happening. I am beginner so sorry if this seems dumb to you.

martin145
  • 1
  • 1

2 Answers2

0

Instead of returning x and then y, how about you return them both? return x, y.

After a return statement you leave the function.

Bharel
  • 23,672
  • 5
  • 40
  • 80
0

Here is how you would return 2 values and call them. Return x immediately exits the function and you won't return y.

def hello(x,y):
    return x,y

x,y=hello(1,2)
print(x,y)
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32