update 0
My test code was very naive and I have to enhance it as follows ...
n=2
times=intervals([9,30],[11,30])
u=[]
v=[]
for t in times:
u+= [[t[0],t[1]]]
for i in range(0,n):
t.append("")
t[3]=3
v+=[t]
print "t:",t
print "v:",v
print "u.index:",u.index([10, 30])
... so from my test code I need to use the value of variable v
for variable times
and I need to use the result of u.index([10, 30])
for my index. BrenBarn finally got through to me, I hope.
My test code that follows ...
n=2
times=intervals([9,30],[11,30])
for t in times:
for i in range(0,n):
t.append("")
t[3]=3
print t
... produces the following print result
[9, 30, '09:30AM', 3, '']
[10, 0, '10:00AM', 3, '']
[10, 30, '10:30AM', 3, '']
[11, 0, '11:00AM', 3, '']
Can the index()
method be used to find, for example, the index in list t
of the "element" [10, 30, ... ]? Or do I need to construct the integer list [930,100,1030,110]
and index() that list, instead? Or are there other suggestions?
Did you even try it, or am I misunderstanding your question?
>>> t = [[9, 30, '09:30AM', 3, ''],
... [10, 0, '10:00AM', 3, ''],
... [10, 30, '10:30AM', 3, ''],
... [11, 0, '11:00AM', 3, '']]
>>> t.index([10, 30, '10:30AM', 3, ''])
2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.