-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreate_Loop_Dictionary.py
More file actions
25 lines (20 loc) · 1001 Bytes
/
Create_Loop_Dictionary.py
File metadata and controls
25 lines (20 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Method 1: {}
amino_acid_galleries = {}
gallery_info = [('Glutamine', 'Help the immune system function and normal brain function and digestion'), ('Cysteine', 'Help prevent side effects due to drug reactions and toxic chemicals')]
# Turn tuples into a dictionary
for name, function in gallery_info: # gallery_info is a list of tuples
amino_acid_galleries[name] = function
print(amino_acid_galleries)
# {'Glutamine': 'Help the immune system function and normal brain function and digestion', 'Cysteine': 'Help prevent side effects due to drug reactions and toxic chemicals'}
# Loop over a dictionary
for name, function in amino_acid_galleries.items():
print(name)
print(function)
# Glutamine
# Help the immune system function and normal brain function and digestion
# Cysteine
# Help prevent side effects due to drug reactions and toxic chemicals
# Find the last 5 amino acid names
for name in sorted(amino_acid_galleries)[-5:]: # Loop over the key
print(name)
# Method 2: dict()