I just started Python 2.7 very recently, but I\'m stuck at this a problem:
Make a program that prints an \"M\" pattern of asterisks. The user shall in
The dumbest approach is to print an increasing number of stars justified left and right until their number reaches N//2
(floor division), the rest is easy.
for n in range(1,N//2+1):
line = bytearray(' ' * N)
line[:n] = line[-n:] = '*' * n
print line
Ha, with this, you can even loop all the way to N
instead of N//2
- since assigning to intersecting ranges will do no harm.