Python Forum

Full Version: List out of range error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,
N=3 (will be 2 at most in the loop I want to create)
T=5 (will start from 2 in the loop I want to create)
I want to print:
x(1)(2),I(1)(1)
x(1)(3),I(1)(2)
x(1)(4),I(1)(3)
x(1)(5),I(1)(4)
x(2)(2),I(2)(1)
x(2)(3),I(2)(2)
x(2)(4),I(2)(3)
x(2)(5),I(2)(4)

I am getting list index out of range error , can you help me or fix it ?
[ for ma in range(1,N):
for a in range(2,T+1):
thevars=[x[ma][a],I[ma][a-1]]
print(thevars)
]
Please show the error code in it's entirety (between the "error" tags) and actual code (between the "code" tags).
for ma in range(1,N):
for a in range(2,T+1):
thevars=[x[ma][a],I[ma][a-1]]
print(thevars)
Error:
IndexError: list index out of range
I do not know how to do it in error and code tags , sorry , I tried but it did not work[/code]
That is not the entire error code.