Buat kamus dari daftar python
fruits = ["Apple", "Pear"]
# Create a dictionary using as keys the values in fruits list
fruit_dictionary = dict.fromkeys(fruits, "In Stock")
print(fruit_dictionary) # {'Apple': 'In Stock', 'Pear': 'In Stock'}
# Alternatively, dictionary comprehension can be used for same purpose
fruit_dictionary = { fruit : "In stock" for fruit in fruits }
print(fruit_dictionary) # {'Apple': 'In Stock', 'Pear': 'In Stock'}
Wissam