Python Forum
Using function *args to multiply multiple arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using function *args to multiply multiple arguments
#6
It looks like the initial answers in fact created more confusion. Their initial understanding of the for loop and how it calculates the result were correct. And also was corect their understanding why the second example (the print) was failing. IMHO the reason for initial confusion of OP is the fact that asterisk is used both as multiplication operator and also to handle variable number of positional arguments

@allusernamestaken, when you use *args (here args is used by convention) it handles variable number of positional arguments. The same way if you use something like **kwargs, it will handle variable number of keyword arguments

also asterisk may be used similarly for extended iterable unpacking
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Using function *args to multiply multiple arguments - by buran - Nov-19-2019, 08:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  calling external function with arguments Wimpy_Wellington 7 1,518 Jul-05-2023, 06:33 PM
Last Post: deanhystad
Question How to compare two parameters in a function that has *args? Milan 4 1,316 Mar-26-2023, 07:43 PM
Last Post: Milan
Sad Iterate randint() multiple times when calling a function Jake123 2 2,108 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  'namespace' shorthand for function arguments? shadowphile 5 2,652 Aug-11-2021, 09:02 PM
Last Post: shadowphile
  *args implementation and clarification about tuple status amjass12 10 4,133 Jul-07-2021, 10:29 AM
Last Post: amjass12
  Checking the number of arguments a function takes Chirumer 3 2,203 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Function - Return multiple values tester_V 10 4,558 Jun-02-2021, 05:34 AM
Last Post: tester_V
  [SOLVED] Good way to handle input args? Winfried 2 2,109 May-18-2021, 07:33 PM
Last Post: Winfried
  Possible to dynamically pass arguments to a function? grimm1111 2 2,229 Feb-21-2021, 05:57 AM
Last Post: deanhystad
  Two Questions, *args and //= beginner721 8 3,582 Feb-01-2021, 09:11 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020