M
M
mrdrkot2022-01-15 21:33:48
Python
mrdrkot, 2022-01-15 21:33:48

How to get the number of variables the user wants to return in Python 3?

Is there some function OutputnNum() that returns the number of variables that the user has specified to the left of the assignment sign when some function F() is run to the right of the assignment sign?

For example, to be able to do this:

def F():
   if OutputnNum() == 1:
      return 1
   elif OutputnNum() == 2:
      return 2, 2

a = F()
print(a) #1
a,b = F()
print(a,b) #2 2


Thanks in advance for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-01-15
@mrdrkot

https://qna.habr.com/q/1095874

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question