python - How to print shapes made of * in horizontal? -
i've made function prints out shapes using *.
my code
def print_saw(tooth_size, number_of_teeth): """print saw drawing""" counter_2 = 0 while counter_2 != number_of_teeth: counter = 1 while counter != tooth_size+1: print("*" * counter) counter = counter + 1 counter_2 = counter_2 + 1
there more code that. that's function prints saw. printed in python so.
>>> print_saw(4, 3) * ** *** **** * ** *** **** * ** *** ****
but want print horizontal. so.
>>> print_saw(4, 3) * * * ** ** ** *** *** *** ************
a simple way without using formatting:
def print_saw(size, number): s in range(size): print(('*' * (s + 1) + ' ' * (size - s - 1)) * number)
gives:
print_saw(5, 3) * * * ** ** ** *** *** *** **** **** **** ***************
Comments
Post a Comment