0
Why for loop is not working for tuple
3 Answers
+ 2
# if you want to use this signature:
def nestEggVariable(salary,save,*growthRates):
# ... and you want to pass many growthRathes as list or tuple, you need to call it this way:
nestEggVariable(1000,5,*g)
# alernatively, if you call it this way:
nestEggVariable(1000,5,g)
# ... you need this function signature:
def nestEggVariable(salary,save,*growthRates):
# more generaly:
def func(*args):
# ... expect to be called this way:
func(arg1,arg2,arg3) # (with any number of arguments)
# if you have a list or tuple of arguments:
call_arg = (arg1,arg2,arg3)
# ... and you do:
func(call_arg) # insteat of func(*call_arg)
# your function will receive the tuple as first argument ^^
Neeraj Agarwal check this link:
https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-kwargs-and-args/
+ 1
Post language name in tags where you have written beginner
Also try printing i and growthRate after for Loop and you will see the problem
Here is the solution
https://www.geeksforgeeks.org/packing-and-unpacking-arguments-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
+ 1
Thanks Guys