Skip to content

Instantly share code, notes, and snippets.

@bryoussef-coder
Last active September 2, 2022 10:56
Show Gist options
  • Save bryoussef-coder/02ee5cffd58debdb1a3324442d7d176e to your computer and use it in GitHub Desktop.
Save bryoussef-coder/02ee5cffd58debdb1a3324442d7d176e to your computer and use it in GitHub Desktop.
Python_YBR
## How do I define a function with optional arguments
Solved it with giving a value to the optional parameter as None:
def myFunc(arg1, arg2 = None):
#do stuff
if arg1 == "abc": #Extremely rare situation
# do sth with arg2
## how do I convert a single digit number into a double digits string?
f"{a:02}"
## How to exit an if clause
def some_function():
if condition_a:
# do something and return early
...
return
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment