Ad

In arguments give list of int. You need return 1 digit which will be sum of digits list's mean.

[3, 7] -> 5 (list's mean)
[523, 687, 953] -> 721 (list's mean) -> 10 (sum of digits) -> 1 (sum of digits)
def mean_sum(nums):
    return mean_sum(round(sum(nums)/len(nums))) if isinstance(nums, list) else nums if nums < 10 and nums > -10 else mean_sum(sum(int(i) for i in str(nums)))
Code
Diff
  • def Calculator(a, b, c='error'):
        try:
            return eval(str(b)+a+str(c))
        except:
            return 0
    • def Calculator(expression):
    • def Calculator(a, b, c='error'):
    • try:
    • return eval(expression)
    • return eval(str(b)+a+str(c))
    • except: