Count Positives
Python
Easy
3 views
Problem Description
Read n integers. Count how many are > 0 and output count.
Input Format
First line n. Second line n integers.
Output Format
One integer count.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
n=int(p[0])
a=list(map(int,p[1:1+n]))
c=0
for x in a:
if x>0:
c+=1
sys.stdout.write(str(c))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!