Format and display elements in python list
Post date: Jan 9, 2015 8:36:46 AM
The main ingredients are tuple() and function join Here is an example:
a = [1/3.0, 1/6.0, 0.678]
print ("elements in the list are ["+', '.join(['%.2f']*len(a))+"]") % tuple(a)
>>> elements in the list are [0.33, 0.17, 0.68]
further resources: