Python zip() function

Python zip() function

Instructor-svgAl-Mamun Sarkar
Mar 26 , 2020

Python zip() function. The following code shows how to solve the HackerRank Zipped! Python collections problem. 

Code:

n, x = map(int, input().split()) 

sheet = []
for _ in range(x):
    sheet.append(map(float, input().split()))

for i in zip(*sheet): 
    print(sum(i)/len(i))

 

Test Input:

5 3
80 90 70 93 80
80 91 87 88 86  
91 90 82 89 90.5

Test Output:

90.0
91.0
82.0
90.0
85.5
  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram