Learn Python programming and more with our Learn to Code course Bundle!
https://josephdelgadillo.com/product/...
Alright! So, let's talk about keyword arguments. The first keyword, or boolean, that we are going to cover is None. Basically, this is the equivalent to null in other languages. So, let's go ahead and write our previous function.
def print_something(name = "Someone", age = "Unknown"):
print("My name is", name, "and my age is", age)
print_something(None, 27)
There isn't a way to pass in an argument that isn't first one being used unless we use keyword arguments. We can also define the variable when we call the function.
def print_something(name = "Someone", age = "Unknown"):
print("My name is", name, "and my age is", age)
print_something(age = 27, name = "Nick")
By using keyword arguments, we can specify which value is supposed to go in a particular variable.
Web - https://josephdelgadillo.com
Subscribe - https://bit.ly/SubscribeJTD
Facebook - / delgadillojt
Auf dieser Seite können Sie das Online-Video Learn Python Episode #18: Keyword Arguments mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Joseph Delgadillo 16 August 2017 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,409 Mal angesehen und es wurde von 33 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!