While I am trying to create a dictionary using dict(x), where x is a slice of another dictionary,d(y) where y is collections.Counter() object. This is the one-liner:
lengths=dict(islice(dict(Counter(input())),3))
The exception I am getting is this
lengths=dict(islice(dict(Counter(input())),3))
ValueError: dictionary update sequence element #0 has length 1; 2 is required
According to my understanding, this error is caused when the update function is called with only one value(instead of key value pair). I know something is bad in the nested function calls, but couldn't find it.
How can I get a slice of dictionary items? Is there a way I could do this without actually iterating through the entire dictionary and updating to a new dictionary?