• + 20 comments

    To keep things clear and simple:

    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) )
    
    • + 5 comments

      unkempt pubes:

      [print(sum(i) / len(i) ) for i in zip( *[map(float, input().split()) for _ in range(int(input().split()[1])) ] ) ]
      
      • + 3 comments

        what does the [1] after split() do??

        • + 1 comment
          [deleted]
          • + 0 comments

            here is solution of problem Zipped in python 2 and python 3 https://solution.programmingoneonone.com/2020/06/hackerrank-zipped-problem-solution-python.html

        • + 0 comments

          as the input for number of students and subjects is given in same line, OP is spliting the input string into list and taking 2nd element of the list to iterate those many times.

        • + 0 comments

          here is problem solution in python programming. https://programs.programmingoneonone.com/2021/02/hackerrank-zipped-solution-python.html

      • + 3 comments

        what does the [1] after split() do??

        • + 0 comments

          .split()returns list. [n] returns n-th element of that list.

          >>> 'hello world'.split()
          ['hello', 'world']
          >>> 'hello world'.split()[1]
          'world'
          
        • + 0 comments

          It's a shortcut of skipping the first input (number of subjects) and going straight for the number of students

        • + 0 comments

          Updated solution is here

          https://www.thecscience.com/2021/08/hackerrank-Zipped-in-python-problem-solution.html

      • + 0 comments

        nyc solution!!!!!!!!!!

      • + 0 comments

        Bad practice to use list comprehensions/map for printing items, better use for loop.

      • + 0 comments

        readability is highly decreased here.

    • + 0 comments

      Excellent! Undertandable to beggeners as well. Like me

    • + 0 comments

      Your code exceeds all cases, but i would add format in sake of robustness.

      print("{0:.1f}".format(sum(i)/len(i)))
      

      For input cases like:

      5 3
      89 90 78 93 25
      90 91 85 88 86  
      91 92 83 89 90.5
      
    • + 0 comments

      uuuuuuuuuuuuuu

    • + 1 comment

      very nice code............................

      • + 1 comment

        What is the use of * symbol here

        • + 0 comments

          It's to specify an arbitrary number of arguments. See: https://stackoverflow.com/questions/287085/what-do-args-and-kwargs-mean

    • + 0 comments

      from statistics import mean . . . . print(mean(i))

    • + 0 comments

      using len(i) is unnecessary and adds more computation per iteration. simply use alreday known value of x

      print(sum(i)/ x)

    • + 0 comments
      N,X=map(int,input().split())
      ll=[]
      for _ in range(X):
          l=list(map(float,input().split()))
          ll.append(l)
      for i in zip(*ll):
          print("{:.1f}".format(sum(i)/X))
      
    • + 0 comments

      we can use print(sum(i)/X) because len(i) is bit confusing

    • + 0 comments

      Almost exactly the same:

      N, X = map(int, input().strip().split())
      L = []
      
      for i in range(X):
              L.append(map(float, input().strip().split()))
      
      for e in zip(*L):
              print(sum(e) / X)
      
    • + 0 comments

      Probably very late to ask , i see this post is 4 years ago .but ... map objects is appended in sheet so in zip(*sheet) the map objects will be unpacked how does zip reaches down to map objects elements ?

    • [deleted]Challenge Author
      + 0 comments

      This solution is more simple and readable

    • + 0 comments

      Exact same solution

      columns,row=map(int,input().split()) grades=[] for _ in range(row): grades.append(list(map(float,input().split()))) for student in zip(*grades): print(sum(student)/row)

    • + 0 comments

      '*' notation helped me!

    • + 1 comment

      what is the meaning of underscore in "for _ in range(x):"

      • + 0 comments

        Hi chin999,

        it is simple 'for' loop abbreviation in Python. range of x means: # of times for loop to be executed.

    • + 0 comments

      why do we put *zip(sheet) and not zip(sheet) what is the difference between this 2? why cant we use the latter?

    • + 0 comments

      why does "_" in 'for loop' means?