THANK YOU!! I finally understand *args and **kwargs after at least a year of studying Python. I still have immense respect for my previous instructor, but this video finally gives Me the level of understand I need to write MY own codes. Thank You again.!! Rob
Great video as always, Bro Code. However, using the if statements there seems unnecessary as the get() method has a second parameter that sets a default value if the key doesn't exist. For example: kwargs.get('apt', '') The default value is set as '' here which wouldn't show up as anything in the output.
Thank you Bro. Taking intro to Scripting right now, every so often the reading material DOES NOT hit the mark for me. Glad you always seem to have something about what I am stuck on, cause I for the life of me could not get what the nonsense the reading material was trying to tell me. Pretty sure I will have to keep coming back to review the video with each prompt I need to code into, but still THank you for the video.
Nice video but, i seem that *args are simple in adding but i found it a little bit complex when i write a code for multiplying so if u can show us 1 example in multiply *args please
At 12:44 a simpler solution would be to just print(f"{kwargs.get('street')} {kwargs.get('apt') or ''}") (That's two single quotes after the word "or"). This would replace 'None' with an empty string, which is what you want.
hi bro code, i love your videos, how many years did it take you to get to the point to where you are at? It is a lot to learn i am a cs student first year thansk for the info
Hey bro, can you make a simple code in python that can print out dates in a sequence that skips several days after a specific number an then repeats? Lets say for example print 5 dates in a range a=5(prints 5 numbers or dates) and b=3(skips next 3) so the output dates should print out like 0,1,2,3,4,8,9,10,11,12,16,17,18,19,20. I want to see how you can do this with your simple and detailed explanation.
a = 5 # Number of dates to print b = 3 # Number of days to skip after printing # Initialize the current date current_date = 0 # Loop to generate and print the sequence of dates for _ in range(a): print(current_date) # Update the current date to the next date after skipping 'b' days current_date += 1 # Check if we need to skip 'b' days if _ % (a + b) >= a: current_date += b
I am confused with **kwargs example, are any of those values associated with each other? It seems like they're not key:value pairs, just individual strings
HELLO GUYS CAN YOU MAKE A PROGRAM THAT SHUFFLES EVERY INPUT LETTER OR NUMBER AND OUTPUTS EVERY POSSIBILITY WITHOUT USING ANY RANDOM OR SHUFFLE FUNCTION. (PERMUTATIONS)
@Bro Code, I have a small program that needs debugging could you kindly help me please? I learnt a lot from your videos but this seems to be a little too much for me to solve. how can i contact you personally please? Thanks in advance buddy :)
May be a bit late, but: in this video he is working with a function, not with a method inside a class. "self" is only used inside classes when you create a method, its a placeholder for the name of the object you create with the help of your class, which serves as a blueprint. A function is a method not bound to a class or an object, a method is a function bound to a class or an object. Its basically the same idea, but the naming varies depending on the context in which the concept is used.
I've been contributing to a repo recently and in there functions' arguments they have `/` and `*` as follows ``` def function(arg1, arg2, /, *, kwarg1=1, kwarg2=2): pass ``` Can someone explain what `/` and `*` doing in the function arguments??? I've tried googling it but `*args` and `**kwargs` keep popping up
Single asterisk as used in function declaration allows variable number of arguments passed from calling environment. Inside the function it behaves as a tuple.