Python Simple Star Drawing Question

Asked 1 years ago, Updated 1 years ago, 359 views

I understand that you draw stars on the Python diagonal using x==y, x==-y, but on the contrary, I don't know how to draw stars on the rest except for the diagonal. Please help me. It's 300 years wide except for the diagonal, so you can fill it with stars at 300.

python

2023-04-11 18:01

1 Answers


for x in range(-30, 30):
 for y in range(-30, 30):
  print( (" ","*")[x == y or x == -y], end="")
 print()

for x in range(-30, 30):
 for y in range(-30, 30):
  print( ("*"," ")[x == y or x == -y], end="")
 print()


2023-04-13 14:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.