Pyramid Builder ⭐
Remember how * repeats a string? "ha" * 4 gives hahahaha.
Now put that inside a loop where the number changes every turn, and something very satisfying happens:
for i in range(1, 5):
print("⭐" * i)
⭐
⭐⭐
⭐⭐⭐
⭐⭐⭐⭐
A pyramid! Each turn, i is bigger, so the row is longer. You wrote two
lines and got a shape.
This works with any character — #, 🍕, ~, whatever you like.
Your mission
- Make a variable
blockholding one emoji or symbol - Use a loop with
range(1, 8)so it runs 7 times - Use
*to printblockrepeateditimes, so row 1 has one block and row 7 has seven
Your code
Press ▶ Run to see what your code does!