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
#4
(Nov-19-2019, 04:16 PM)stullis Wrote: Once it reaches the end last index of the tuple created by *args, it terminates without running the loop body. In effect, the for loop would perform 2 * 5 * 6.
Would you please guide me with more examples or a link for supplementary readings to understand what you're saying?

My understanding was that the for loop begins then,
z = 1 and 2, 5 & 6 are num and
1* = 2
1* = 5
1* = 6
...wait, I'm even more confused. I don't think I understood it at all before.


(Nov-19-2019, 04:19 PM)Gribouillis Wrote: Here is a printing example with the *args argument
>>> L = [2, 5, 6]
>>> print(*L)
2 5 6

Oh, nice. you can unpack it as well. Thank you.
Reply


Messages In This Thread
RE: Using function *args to multiply multiple arguments - by allusernametaken - Nov-19-2019, 07:42 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