@hbknjr - this is not so good solution as it (i) does not gurantee the order in which arguments were supplied (ii) the number of arguments, e.g.
you need to put efforts when parsing args
a similar, but in my opinion better solution is to force using keyword arguments (only python3)
get_formated_name('Hooker', 'Lee', 'John')
get_formated_name('Hooker', 'Lee', 'John', Jimi', 'Hendix')
you need to put efforts when parsing args
a similar, but in my opinion better solution is to force using keyword arguments (only python3)
def full_name(*, first_name=None, middle_name=None, last_name=None): names = (first_name, middle_name, last_name) return ' '.join(name for name in names if name) print(full_name(first_name='john', middle_name='lee', last_name='hooker')) print(full_name(first_name='jimi', last_name='hendrix')) print(full_name(first_name='madonna')) print(full_name('john', 'lennon'))
Output:john lee hooker
jimi hendrix
madonna
Traceback (most recent call last):
File "example.py", line 8, in <module>
print(full_name('john', 'lennon'))
TypeError: full_name() takes 0 positional arguments but 2 were given
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs