Quantcast
Viewing all articles
Browse latest Browse all 14069

hackerrank average function in python

hi guys i tried runnig this code bit it keeps failing at most of the test i don't what the problem is!!

#!/bin/pythonimport mathimport osimport randomimport reimport sys# write your code heredef avg(*num):    if len(num)==0:        return None    sum=0    for i in num:        sum=sum+i        moy=sum/len(num)    return(moy)if __name__ == '__main__':    fptr = open(os.environ['OUTPUT_PATH'], 'w')    nums = map(int, raw_input().split())    res = avg(*nums)    fptr.write('%.2f' % res +'\n')    fptr.close()

Viewing all articles
Browse latest Browse all 14069

Trending Articles