Apr-08-2018, 07:05 PM
If you try to print the array as an array, it will always contain comma's because that is how python represents the array contents.
You need to create a function that loops through the array and prints without commas.
Something like:
You need to create a function that loops through the array and prints without commas.
Something like:
class PrintList: def print_list(self, aname): firstitem = True if isinstance(aname, list): print('[', end='') for item in aname: if isinstance(item, list): if firstitem: firstitem = False else: print() self.print_list(item) else: print(' {} '.format(item), end='') print(']', end = '') else: print('Not a list') def tryit(): p = PrintList() p.print_list([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) if __name__ == '__main__': tryit()test:
Output:[[ 1.0 2.0 3.0 ]
[ 4.0 5.0 6.0 ]
[ 7.0 8.0 9.0 ]]