Python: how do I call `print` from `eval` in a loop?
Python: how do I call `print` from `eval` in a loop? Question: When I call print from eval: def printList(myList): maxDigits = len(str(len(myList))) Format = ‘0{0}d’.format(maxDigits) for i in myList: eval(‘print “#{0:’ + Format + ‘}”.format(i+1), myList[i]’) it gives an error: print “#{0:01d}”.format(i+1), myList[i] ^ SyntaxError: invalid syntax I tried to make use of this, …