Instead of a simple star pattern, let’s take user input to decide how many rows to print.
☆
☆☆
☆☆☆
☆☆☆☆
☆☆☆☆☆
i = int(input("Enter the number of rows: "))
star = 1
while True:
print("☆" * star)
if star == i:
break
star += 1
input()returns a string by default. Convert it toint.while Truecreates an infinite loop.- Each iteration prints stars and increments by 1. When it matches the input,
breakstops the loop.
Entering 7 prints stars from 1 to 7 rows.