As mention
input
name is used,if not sure of build in names test it.# Also not okay name is used >>> input <built-in function input>
# foo can be use get a NameError >>> foo Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'foo' is not defined name 'foo' is not defined
(Mar-08-2019, 02:39 PM)dan789 Wrote: What´s the variable of that input? How can I use it´s value inside that function?It can be None or any that user give that's the point of
default arguments
.def function(param1, my_input=""): if my_input == '': return f'No argument given so i just return <{param1}> and <{repr(my_input)}>' return f"Ohh user want something else than '' so i return <{param1}> and <{my_input}"Use:
# Will not get a error if give one argument >>> function('hello') "No argument given so i just return <hello> and <''>" >>> function('hello', 999) "Ohh user want something else than '' so i return <hello> and <999>" >>> function('hello', 'world') "Ohh user want something else than '' so i return <hello> and <world>"