How can i eval subindex on list[ ][ ] ?

J

jairodsl

Excuse me, i was trying in too many ways but i couldnt access subindex
on a list , the problem is the next:

I have

indif=[[0,'A'],[1,'B'],[2,'C'],[3,'D']]

and

indic=[[0,'B'],[1,'C'],[2,'D'],[3,'E']]

i need to eval if indic[j] is equal to indif[j]

I used a double for but i had got "list index out of range". How can i
do ???

Thanks a lot,

Cordially,

jDSL
 
J

James Stroud

jairodsl said:
Excuse me, i was trying in too many ways but i couldnt access subindex
on a list , the problem is the next:

I have

indif=[[0,'A'],[1,'B'],[2,'C'],[3,'D']]

and

indic=[[0,'B'],[1,'C'],[2,'D'],[3,'E']]

i need to eval if indic[j] is equal to indif[j]

I used a double for but i had got "list index out of range". How can i
do ???

Thanks a lot,

Cordially,

jDSL


py> i = 1
py> j = 0
py> indif[j] == indic[j]
True


Works for me.

James
 
G

Gabriel Genellina

Excuse me, i was trying in too many ways but i couldnt access subindex
on a list , the problem is the next:

I have

indif=[[0,'A'],[1,'B'],[2,'C'],[3,'D']]

and

indic=[[0,'B'],[1,'C'],[2,'D'],[3,'E']]

i need to eval if indic[j] is equal to indif[j]

I used a double for but i had got "list index out of range". How can i
do ???


Posting your actual code would help. indif[j] should be fine, if i
is between 0 and 3 inclusive, and j is 0 or 1.


--
Gabriel Genellina
Softlab SRL






__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
 
T

Terry Reedy

| jairodsl wrote:
| > Excuse me, i was trying in too many ways but i couldnt access subindex
| > on a list , the problem is the next:
| >
| > I have
| >
| > indif=[[0,'A'],[1,'B'],[2,'C'],[3,'D']]
| >
| > and
| >
| > indic=[[0,'B'],[1,'C'],[2,'D'],[3,'E']]
| >
| > i need to eval if indic[j] is equal to indif[j]
| >
| > I used a double for but i had got "list index out of range". How can i
| > do ???
| >
| > Thanks a lot,
| >
| > Cordially,
| >
| > jDSL
| >
|
| py> i = 1
| py> j = 0
| py> indif[j] == indic[j]
| True

Or, if you mean for every i and j, just

indif == indic

and let the types equality method do the work for you.
 
R

raghu

its working for me i think its better to mention the value of i and j
for both lists or you might have done mistake while formatting strings
it should be %s for strings and %d for numbers if any subelement in
lists does not formatted properly it may lead to error
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top