- 1

Why is this code not printing “D” Pattern

for row in range(7): for col in range(5): if (col == 0 or col == 4 and row not in (0,6) or row in (0,6) and 0 < col < 4) : print("D", end=" ") else: print(end=' ') print() It should print “D”. But it printing - **** ** ** ** ** ** ***

23rd Jan 2021, 7:30 AM
Balraj Singh
3 odpowiedzi
+ 2
indent the else for one more space
23rd Jan 2021, 8:16 AM
Oma Falk
Oma Falk - avatar
+ 5
Balraj Singh , just a hint: ▪︎ try to use correct indentation width - 4 spaces are recommended. readability in code editor but more in Q&A will be much better. thanks!
23rd Jan 2021, 10:04 AM
Lothar
Lothar - avatar
+ 3
Write your code in Insert Code, because you should to click Enter after (:) (for loop) and (if statement) https://code.sololearn.com/cQSNK1q9I1zc/?ref=app
23rd Jan 2021, 9:05 AM
Imad Ezzahi
Imad Ezzahi - avatar