How to ignore an output of a multi-output function in Python? -
this question has answer here:
- ignore python multiple return value 8 answers
suppose have function:
def f(): ... ... ... return a,b,c
and want b in output of function. assignment have use?
thanks.
you can unpack returned tuple dummy variables:
_, keep_this, _ = f()
it doesn't have _
, unused.
(don't use _
dummy name in interactive interpreter, there used holding last result.)
alternatively, index returned tuple:
keep_this = f()[1]
Comments
Post a Comment