Can't I use that name when each nested list has a name in the nested list?

Asked 1 years ago, Updated 1 years ago, 91 views

t7=(3, 17, 34, 57)
t8=(5, 39, 57)
t9=(8, 16, 23, 45, 54, 58)
t10=(2, 20, 30)
t11=(3, 19, 34, 57)
t12=(8, 16, 27, 45, 54, 58)
t13=(3, 17, 34, 57)
t14=(2, 28, 30)
t15=(4, 17, 34, 57)
t16=(8, 16, 23, 45, 52, 58)
t17=(3, 17, 34, 57)
t18=(2, 20, 38)
t19=(3, 17, 32, 57)
times=(t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19)

There's a tuple like this (I'll call it a list for convenience), but if you print out the times, of course it's nested Nested list is t7, t8... If you can think of it as having a name like this

At this time

    T=[7,34]

    for i in range(len(times)):

    # If T[0]-7 == i: No

    #  If T[0]==times[i]: I want to satisfy if in the same way

(That is, I want to satisfy if with t7==(t7 in column 0 which is the name of the overlapping list) What should I do when I do it?

list nested-list

2022-09-22 17:55

1 Answers

The question is not clear, but it is possible to change the following.

t7=(3, 17, 34, 57)
t8=(5, 39, 57)
t9=(8, 16, 23, 45, 54, 58)
t10=(2, 20, 30)
t11=(3, 19, 34, 57)
t12=(8, 16, 27, 45, 54, 58)
t13=(3, 17, 34, 57)
t14=(2, 28, 30)
t15=(4, 17, 34, 57)
t16=(8, 16, 23, 45, 52, 58)
t17=(3, 17, 34, 57)
t18=(2, 20, 38)
t19=(3, 17, 32, 57)
times=(t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19)

for i, t in enumerate(times):
    if t == t7:
        print('%dth element of `times` list equals t7.'%i)

Results

0th element of `times` list equals t7.
6th element of `times` list equals t7.
10th element of `times` list equals t7.


2022-09-22 17:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.