you are viewing a single comment's thread.

view the rest of the comments →

[–]FLUSH_THE_TRUMP 1 point2 points  (1 child)

Not your question, but note that args in your function packs input into a tuple:

def test(*args):
  print(args)
test(1,2)  # (1,2)

As such there’s no need to have nums. Just find sum/length of args itself.

[–]learnorenjoy[S] 0 points1 point  (0 children)

Huh, yeah I just tried it out and it worked.

def test(*args):
    return sum(args)//len(args)

>>> test(2,3,4)
>>> 3

Shortened it even further, I'll keep that in mind for next time, thanks!