Right Triangle Star Print
Python
Easy
6 views
Problem Description
Read n, output a right triangle of stars. Line i has i stars (1 to n).
Input Format
One integer n.
Output Format
n lines pattern.
Official Solution
import sys
s=sys.stdin.read().strip()
try:
n=int(s)
except Exception:
n=0
out=[]
cur=''
for _ in range(n):
cur+='*'
out.append(cur)
sys.stdout.write('\
'.join(out))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!