Akansha Yadav shows how to use kwargs in Python to accept any number of named arguments in a function. She demonstrates iterating over key-value pairs with a for-loop and calls the function twice with different argument types to show how kwargs handles both numeric and string values.
Chapters
Hello everyone, welcome back to my YouTube channel. In today's video, we will discuss about the keyword argument in function. So let's write down a function. In this function, I am going to use double asterisk symbol keyword argument, then writing a for loop which I am going to iterate it to the item that I am going to pass as an in the function basically. Now I am going to call my function. So once I am calling my function, I am going to call it with a different number of values. So first I am going to call it with the numeric value. I am going to assign a is equals to— basically these are going to be the random, so you can, you know, pass on multiple values at a time. And second time I'm using the mixed data type, it means string also and the numbers also. So let's check out the output, what's going to be the output. So in the output, basically keyword argument will let you work with the different, uh, numbers of inputs. So basically if you are calling a function, you can call it with the as many number of arguments that you wanted to pass. So if you can see over here, I am able to iterate it to the items that I have passed on to the function. So if you like the video, don't forget to hit the like button and subscribe to the channel for more videos like this. We'll meet in the next video.