python - How to combine two for loops in Python3 -


how result here in python3 ?

---# --## -### #### 

i want combine 2 loops. code:

import sys  num_steps = int(sys.argv[1]) symb1 = "-" symb2 = "#"  in range(num_steps + 1):      print(symb2 * i)  j in range(num_steps-1, 0, -1):      print (symb1 * j) 

result :

# ## ### #### --- -- - 

you don't need 2 loops - use bit of math instead. know how many characters need 1 symbol, know how many characters need other symbol:

for in range(1, num_steps + 1):     print(symb1 * (num_steps - i) + symb2 * i) 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -