Where is the problem with this code?
def my_average(*num):
s, count = 0, 0
for nums in num:
if type(nums) == int:
s += nums
elif type(nums) == float:
s += nums
elif type(nums) == str:
for k in nums:
float_num = float(k)
s += float_num
count += 1
return round(s / count, 2)
test_case = (2, 3, 25, '234.123123', 3, 1, 0)
print(my_average(*test_case))
Actually, I wanted to convert the decimal string into a decimal number and use it in my calculations.
To convert the entire tuple to
floatyou can usewhich you can sum with
and get the average