+ 2

HELP ME WITH THIS CODE

IF WE WILL take three arguments instead of two then how will this code looks and what changes we should make into it https://code.sololearn.com/c73ID5HzqsE7/?ref=app

14th Feb 2022, 2:57 PM
IDIOT KID
IDIOT KID - avatar
7 Answers
+ 1
#IF WE WILL TAKE THREE ARGUMENTS x,y,z THEN HOW CAN WE SOLVE THIS. def add(x,y,z): return x + y + z def do_twice(func,x,y,z): return func(func(x,y,z),func(x,y,z),func(x,y,z)) a = 78 b = 5 c = 10 print(do_twice(add,a,b,c))
14th Feb 2022, 3:04 PM
Mohammadmehdi Karami
Mohammadmehdi Karami - avatar
+ 2
Jayakrishna🇮🇳 THANKS BROO I GOT ANSWER. BUT I DON'T KNOW ABOUT *kwarg FUNCTION BUT REALLY APPRECIATE YOUR ANSWER THANKS FOR HELP.
14th Feb 2022, 3:15 PM
IDIOT KID
IDIOT KID - avatar
+ 1
Add one more patameter as you added 2 => x, y . Or else, use *arg variable arguments *for any number of argument passing........ * def add(x,y, *arg): return x + y+sum(arg) def do_twice(func,x,y,*arg): return func(func(x,y,*arg),func(x,y,*arg)) a = 78 b = 5 c = 4 print(do_twice(add,a,b,c)) print(do_twice(add,1,2,3,4,5,7,8,9)) edit: *arg takes any variable number of arguments.. https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-JUMP_LINK__&&__python__&&__JUMP_LINK-3
14th Feb 2022, 3:10 PM
Jayakrishna 🇮🇳
+ 1
Mohammadmehdi Karami THANKS I JUST GOT IT BY LOOKING CODE AGAIN. AND YOUR EXPLANATION IS SANE AS ME. THANK YOU VERY MUCH
14th Feb 2022, 3:14 PM
IDIOT KID
IDIOT KID - avatar
+ 1
It's an alternative. IDIOT KID I added in explanation, the other way but it is already answered when I see after my post.. Hope this helps to know more if you want about *arg, and **kwarg. I mean actually *arg => variable number of argument pass.. I edited it see again.. https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-JUMP_LINK__&&__python__&&__JUMP_LINK-3 hope it helps.. you're welcome...
14th Feb 2022, 3:24 PM
Jayakrishna 🇮🇳
0
def add(*arg): return sum(arg) def do_twice(func,*arg): return func(func(*arg), func(*arg)) a=6 b=7 c=9 d=15 print(do_twice(add,a,b,c,d))
15th Feb 2022, 10:50 AM
okonkwo calistus
okonkwo calistus - avatar
0
)+?&?++€#2?
16th Feb 2022, 11:12 AM
Musaxon Muzaffarov