In python to print a formatted string with ints and strings, I'd usually do :
print '%d %d - %s' %(x,y, mystr)
Is there anything similar for printing out a list? I have:
L= [1,0,0]
name = 'V'
and I want the output to be :
v(1,0,0)
Is there anything similar to %d for list objects?
If you want complete control how the list gets rendered, you'll have to format it separately.
In your case, the code would be something like:
items = [1,0,0]
name = 'V'
formatted = '%s(%s)' % (
name,
','.join(str(it) for it in items)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With