lechtlr wrote: > I would very much appreciate, if someone can give suggestions to implement > a loop to generate a string in the following format. > Variables with assigned values are given in A: > A = {a1:2.0, a2:4.0,………,an:5.0} > I want to transform what is in the dictionary into a string in the > following format: > X = ‘a1:2.0, a2:4.0, ……,an:5.0’ > I want to implement a loop to generate X for a given A with varying n. > Is there a way to do this in python..?
Is this good enough? >>> A = dict(a1=2.0, a2=4.0, a3=3.0, a4=4.0, a5=5.0) >>> A {'a1': 2.0, 'a3': 3.0, 'a2': 4.0, 'a5': 5.0, 'a4': 4.0} >>> str(A) "{'a1': 2.0, 'a3': 3.0, 'a2': 4.0, 'a5': 5.0, 'a4': 4.0}" If not, just strip out what you do not like. Cheers, Alan Isaac _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion