Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

hackerrank average function in python

$
0
0

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 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>