0

I seem to have a little problem here in this loop if else. Here my if statement doesn't works. My all rows gets red in colour idk probably my first condition gets corrects all time. Also when i put else's statement first my rows gets blue in colour.

from tkinter import *
def columns(clmn):
    for i in range(9):
        if i == 3 or 4 or 5:
            Spinbox(from_=1, to=9, bg='red').grid(row=i, column=clmn)
        else:
            Spinbox(from_=1, to=9, bg='green').grid(row=i, column=clmnSpinbox(from_=1, to=9, bg='blue').grid(row=i, column=clmn)

for i in range(9):
    columns(i)
Dark_Shade
  • 11
  • 2
  • Please avoid that mistake I have done in else statement block code(Spinbox...) My bad – Dark_Shade Jun 10 '22 at 15:12
  • 1
    "My all rows gets red in colour idk probably my first condition gets corrects all time." It's good that you had the idea. The next step in [debugging](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) the code is to *test* that hypothesis. For example: try the code in isolation, by just making a function with that `if` block. Try different values of `i` and see whether the block is entered. Try considering the *condition* by itself: for example, if you try `0 == 3 or 4 or 5` at the interpreter prompt, what does it give back? – Karl Knechtel Jun 10 '22 at 15:14

0 Answers0