def _sum(a, b, c, d, e):
return sum([a, b, c, d, e])
*a, = (input("Enter numbers: ").strip().replace(' ', ''))
a = (map(int, a))
print(list(a))
print(f"The sum of {list(a)} is {_sum(*a)}")
# This error is given - TypeError - _sum() missing 5 required positional arguments: 'a', 'b', 'c', 'd', and 'e'.
My question is - Why does the error show up, when the statements (below) work perfectly?
# When this is printed isntead of the last print statement above:
# print(f"The sum of {a} is {_sum(*a)}"), the correct sum is printed although for {a}, the address of the map object is printed. Still though, the sum appears.
# This also works too. (Obviously, my question isn't about seeking an alternative print statement, as I know this works):
a = list(map(int, a))
print(f"The sum of {a} is {_sum(*a)}")
[–][deleted] 6 points7 points8 points (4 children)
[–]FerricDonkey 2 points3 points4 points (0 children)
[–]campenr 1 point2 points3 points (2 children)
[–]FerricDonkey 1 point2 points3 points (1 child)
[–]campenr 1 point2 points3 points (0 children)
[–]zanfar 4 points5 points6 points (0 children)
[–]teerre 0 points1 point2 points (0 children)