"✍️"
# @workUnit
def stars(height: int):
if height < 0:
raise Exception("Height is negative.", height)
for i in range(height):
print("*" * (i+1))
"🔒"
# @check
# @title: check 1
stars(10)
#Result
#*
#**
#***
#****
#*****
#******
#*******
#********
#*********
#**********
"🔒"
# @check
# @title: height=0
stars(0)
#Result
"🔒"
# @check
# @title: no parameter
try:
stars(-5)
except Exception as e:
print(type(e))
print(e.args)
#Result
#<class 'Exception'>
#('Height is negative.', -5)
To embed this program on your website, copy the following code and paste it into your website's HTML: