D= dict[a= 2, b=4, c=1, d=3]
I am using the above dictionary after sorting (ascending order) and displaying the sorted value along with the lowest value.
Desired output in the dialogue box
c=1
a=2
d=3
b=4
c lowest value is 1
I am trying the following code:
D dict[a= 2, b=4, c=1, d=3]
f= sorted(D.items(), key=operator.itemgetter(1))
g= f[0]
f= [str(x) for x in f]
g= [str(x) for x in g]
msg= '\n'.join(f) + 'lowest value is\n'.join(g)
dlg= wx.MessageDialog(self,msg,"lowest value",wx.OK)
dlg.showModal()
dlg.Destroy()
using this we are getting:
(c=1)
(a=2)
(d=3)
(b=4)c
lowest value is 1
we do not want ‘c’ after b=4 instead we want ‘c’ in the next line as in desired output.
please help…
Insert extra newline characters:
although the last line would be more logically built as:
And how about your dictionary definition?
was meant as
?