我有2个名单:
name = ["Stirling","Lana","Cyril","Pam","Ray","Cheryl"]
alias =["Duchess","Truckasaurus","Chet","Cookie Monster","Gilles de Rais","Cherlene"]
我需要创建一个字典,使得名称是键,别名是值,以这种特殊方式:
Stirling : Duchess
此外,我必须使用for循环来执行此操作。
答案 0 :(得分:1)
你可以简单地zip
。
name = ["Stirling","Lana","Cyril","Pam","Ray","Cheryl"]
alias =["Duchess","Truckasaurus","Chet","Cookie Monster","Gilles de Rais","Cherlene"]
my_dict = dict(zip(name, alias))