python class output about defaultdict(set) -


i new learner on python , built class solve permutation problem :

from collections import defaultdict  class permutation:     def __init__(self, *args, length = none):         self.args = args      def __str__(self):         p = defaultdict(set)         return f'{p}'  p = permutation(3,5,1,4,2) p print(p) 

when print(p) output like:

defaultdict(<class 'set'>, {3: {1}, 5: {2}, 4: {4}}) 

but output expected values grouped it's key , sorted,just like:

(3 1)(4)(5 2) 

could use str() or sth else?i tried convert list still can not value set:( thanks!


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -