[英]How to modify the elements of one list based on another
I have two lists like 我有两个清单
lst1 = ['a', 'b', 'c', 'd', 'e']
lst2 = ['q', 'r', 's']
Now, suppose I generate a mapping from list2 to list1 one like (4, 0, 3) meaning update the 4th element of list1 with the 0th element of list2, update the 0th element of list1 with the 1st element of list2, etc. such that the resulting list looks like 现在,假设我生成了一个从list2到list1的映射,例如(4,0,3),这意味着用list2的第0个元素更新list1的第4个元素,用list2的第一个元素更新list1的第0个元素,以此类推。结果列表看起来像
lst1 = ['r', 'b', 'c', 's', 'q']
How can I do this? 我怎样才能做到这一点?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.