Python3 Solution
\n\nclass Solution:\n    def numberOfBeams(self, bank: List[str]) -> int:\n        ans=0\n        prev=0\n        for i in bank:\n            res=i.count(\'1\')
\n```\nclass Solution:\n    def numberOfBeams(self, bank: List[str]) -> int:\n        ans=0\n        prev=0\n        for i in bank:\n            res=i.count(\'1\')\n            if res:\n                ans+=prev*res\n                prev=res\n        return ans        \n```
['Python', 'Python3']