'Why using *args in defining functions is storing just one value
I am having a problem using *args in a function I am defining. Here is an example of one code:
def feet_to_meter(*args):
"""
:param *args: numeric values in feet
:output: returns list of values in meter
"""
value_list = [ ]
conversion_factor = 0.3048
for arg in args:
try:
value_list.append(arg * conversion_factor)
except TypeError:
print(str(arg) + "is not a number")
return value_list
print ("Function call with 3 values: ")
print(feet_to_meter(3, 1, 10))
I understand that the code should convert the 3 values but somehow after executing the program I only get the result of the first value. I am using Pydroid 3.
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
