why it doesn't work? it should work here
def say_hi(P1, P2 = None, P3 = None, P4 = None, P5 = None):
if [P2, P3, P4, P5] is [not None, None, None, None]:
print(f'hi {P1}')
print(f'hi {P2}')
say_hi('Jack', 'Rose')
why my code doesn't work? it execute nothing
Is meaning that these two object's is the same object. Not the equal. You need "==". https://dbader.org/blog/difference-between-is-and-equals-in-python
Try this.
def say_hi(*P):
for p in P:
print(f'hi {p}')
say_hi('Jack', 'Rose')
You can call function with number of parameters you need. All this parameters will be element of array "P".
You can read this about python function and parameters.