Python - Functions with Optional Arguments

Published: 10 June 2021
on channel: codevev
502
11

#Python #Shorts

It is somewhat common to have functions that have arguments that are optional. To create such a function, your arguments need default values. To achieve that, just set the default value right in the function definition. Be careful though, optional arguments MUST appear after all other arguments. And lastly, don't ever use mutable types, such as lists, as default arguments. Use None instead.
-------------------------------------------------------------------------------------
Links:
Blog: https://evgenyurubkov.com
Twitter:   / evgenyurubkov  
Instagram:   / evgenyurubkov  
Youtube:    / @codevev  


Watch video Python - Functions with Optional Arguments online without registration, duration hours minute second in high quality. This video was added by user codevev 10 June 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 502 once and liked it 11 people.