Ask your own question, for FREE!
Computer Science 6 Online
OpenStudy (anonymous):

In Pytthon, how can I use the values from one function in another. This is my code. def call_x(): x=5 y=10 return x,y def x_squared(): call_x() print(x) print(y) print(x_squared())

OpenStudy (anonymous):

```python def call_x(): x=5 y=10 return x,y def x_squared(): x,y = call_x() # <---- print(x) print(y) print(x_squared()) ```

OpenStudy (anonymous):

Hello @pitamar Thanks for responding. I actually found another way which is to let result = call_x() and i then set x=result[0] and y=result[1]. Your method is simpler. Thanks again.

OpenStudy (anonymous):

sure np =)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!