code with no tuple gets : IndexError: tuple index out of range - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: code with no tuple gets : IndexError: tuple index out of range (/thread-30737.html) |
code with no tuple gets : IndexError: tuple index out of range - Aggam - Nov-03-2020 Hello! I'm in the works of a flask app which I already had issues with and some nice ppl helped me, and am having other issues... I have this if statement: if not ((lines[4] == lines[6] == dataseg[0]) & (lines[5] == dataseg[1])):and I get this error: The full error being: Can u guys help me? (sry my code is a mess LMAO)My code: https://pastebin.com/ukMv4nTy RE: code with no tuple gets : IndexError: tuple index out of range - bowlofred - Nov-03-2020 Without the code, we can't help much. But the error suggests that one of those variables is a tuple and the index is too large. Before the if you could print the types of them: print(f"dataseg is of type {type(dataseg)} and has {len(dataseg)} elements.") print(f"lines is of type {type(lines)} and has {len(lines)} elements.")That won't tell you why you have a tuple, but it will tell you which one it is and its length. RE: code with no tuple gets : IndexError: tuple index out of range - Aggam - Nov-03-2020 (Nov-03-2020, 04:32 PM)bowlofred Wrote: Without the code, we can't help much. But the error suggests that one of those variables is a tuple and the index is too large. I solved it, thanks ! RE: code with no tuple gets : IndexError: tuple index out of range - ndc85430 - Nov-04-2020 Did you really mean to do a bitwise and? RE: code with no tuple gets : IndexError: tuple index out of range - Aggam - Nov-04-2020 (Nov-03-2020, 04:32 PM)bowlofred Wrote: Without the code, we can't help much. But the error suggests that one of those variables is a tuple and the index is too large. I fixed i,Thanks for your help! |