May-10-2017, 07:18 AM
how can i make a dictionary comprehension for the dictionary being built in this code snippet?
aws_regions = [ ('us-east-1', 'use1', 'N. Virginia' ), ('us-east-2', 'use2', 'Ohio' ), ('us-west-1', 'usw1', 'N. California' ), ('us-west-2', 'usw2', 'Oregon' ), ('ca-central-1', 'cac1', 'Central' ), ('eu-west-1', 'euw1', 'Ireland' ), ('eu-west-2', 'euw2', 'London' ), ('eu-central-1', 'euc1', 'Frankfurt' ), ('ap-southeast-1', 'ase1', 'Singapore' ), ('ap-northeast-1', 'ane1', 'Tokyo' ), ('ap-northeast-2', 'ane2', 'Seoul' ), ('ap-southeast-2', 'ase2', 'Sydney' ), ('ap-south-1', 'aps1', 'Mumbai' ), ('sa-east-1', 'sae1', 'Sao Paulo' ), ] aws_regions_dict = {} for r in aws_regions: aws_regions_dict[r[0]] = r aws_regions_dict[r[1]] = rthis dictionary will have keys from both long names in the first column and short names in the second column. this is what i don't how to do in comprehsions.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.