The pass keyword in a Python function
There are cases when you need to write a function template, but there is no code for it yet. If you leave the function body empty, Python will immediately return an error:
def func(test): # will display an error
In this case, the pass keyword should be used. It fills the empty space in the function body, and no error will be returned:
def func(test):
pass
The following code is given:
num1 = 2
num2 = 3
def func(num1, num2):
res = func(num1, num2)
print(res)
Rewrite it to avoid the error output.
The following code is given:
tst1 = 'abc'
tst2 = 'def'
def func1(txt):
return txt.upper()
def func2(txt1, txt2):
res = func2(func1(tst1), tst2)
print(res)
Rewrite it to avoid the error output.