# Basic syntax:
list_of_keys = list(dictionary.keys())
# To get all the keys of a dictionary as a list, see below
newdict = {1:0, 2:0, 3:0}
list(newdict)
# Output:
# [1, 2, 3]
>>> newdict = {1:0, 2:0, 3:0}
>>> [*newdict]
[1, 2, 3]
"""
In [1]: newdict = {1:0, 2:0, 3:0}
In [2]: %timeit [*newdict]
107 ns ± 5.42 ns per loop
In [3]: %timeit list(newdict)
144 ns ± 7.99 ns per loop
In [4]: %timeit [k for k in newdict]
257 ns ± 21.6 ns per loop
"""
>>> list(newdict.keys()) # don't do this.
newlist = list()
for i in newdict.keys():
newlist.append(i)
dict(zip(a, b))
list(newdict.keys())
List<string> keyList = new List<string>(this.yourDictionary.Keys);
list_of_keys = list(dictionary.keys())
Dictionary<string, int> data = new Dictionary<string, int>();
data.Add("abc", 123);
data.Add("def", 456);
foreach (string key in data.Keys) // look carefully Keys is used with "s" in it
{
Console.WriteLine(key);
}