How can I have *args and another parameter after? | Sololearn: Learn to code for FREE!

0

How can I have *args and another parameter after?

Like let's say I have an array with numbers [1, 2, 3, 4, etc.] and I want to get all of them except the last one in the *args and the last one in another arg. How can I do that?

4/22/2021 9:01:03 AM

Alexander Shestakov

4 Answers

New Answer

+4

args = args[:-1] # every arg but the last args.append(<whatever>) # put whatever on the end

+1

According to the Tutorial, Python Core 95.1: The parameter *args must come after the named parameters to a function. The name args is just a convention; you can choose to use another.

+1

Rik Wittkopp I just saw that but thank you.

+1

Slick Thank you