I want to type a
(from list1
) and get 1
(from list2
), and I don't want to use dict{zip(a,b)}
. Is this possible? Don't want to type something like dict['a']
, just a
.
List1=['a', 'b', 'c']
List2=[1, 24, 35]
print(a)
I want to type a
(from list1
) and get 1
(from list2
), and I don't want to use dict{zip(a,b)}
. Is this possible? Don't want to type something like dict['a']
, just a
.
List1=['a', 'b', 'c']
List2=[1, 24, 35]
print(a)
Try creating a function and passing the array and the string you want to fetch as a argument. Inside the function use a for-loop to match the items of the array and returning the matching item.
Assuming the lists are same length and the position are always aligned, you can do
List1=[a, b, c]
List2=[1, 24, 35]
List2[List1.index(a)]