The problem is solved. thanks everyone
Asked
Active
Viewed 71 times
-1
-
2`self.order > []` clearly does not do what you think it does. `[1, 1] > []` is `True`. – DeepSpace Jul 21 '21 at 14:14
-
Instead, use `while self.order:` – DeepSpace Jul 21 '21 at 14:16
-
@DeepSpace an empty list is not greater than itself, so it's weird that OP gets this error. `[1, 1] > []` is `True`, but `[1, 1].pop(0)` wouldn't throw that error – Pranav Hosangadi Jul 21 '21 at 14:27
-
OP, can you [edit] your question to include the _exact_ output you get? Condense your code down to a [mre]: remove irrelevant parts of your code like the references to objects and functions that aren't included here. I suspect one of your functions modifies `self.order` _after_ it's in the loop, so `self.order.pop(0)` is no longer possible. I'm not able to replicate your issue with a simple `l = [1, 2, 3, 4, 5]; while l > []: print("Before: ", l, end=""); l.pop(0); print("; After: ", l)` – Pranav Hosangadi Jul 21 '21 at 14:29
-
We _don't_ want your whole code. Please do some [debugging](//ericlippert.com/2014/03/05/how-to-debug-small-programs/) and condense your code down to a [__minimal__ reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Pranav Hosangadi Jul 22 '21 at 13:03
-
@PranavHosangadi I think my problem is after I rapidly click the buttons, the button will trigger the command function for additional times without clicking. I'm still confused, I got the lambda after the command tag. btw, the whole code is actually very minimal – JadeChest Jul 22 '21 at 14:08
1 Answers
0
If you want to have the condition to test that self.order should not be empty list. then use condition as len(self.order)>0 this should be the appropriate instead the one you have.
dinesh kumar
- 95
- 1
- 4
-
2Empty lists are [falsy](https://stackoverflow.com/q/39983695/843953) in python. You don't need to check `if len(self.order) > 0`, `if self.order` will work just fine – Pranav Hosangadi Jul 21 '21 at 14:22
-
-
but even I change the condition to while self.order. I still got this error... – JadeChest Jul 21 '21 at 19:43