How can I print lists without brackets and commas?
I have a list of permutations like this:
[1, 2, 3]
[1, 3, 2] etc..
I want to print them like this: 1 2 3
Use str. replace() to remove a comma from a string in Python replace(',', ”) to replace every instance of a ',' in str with ” .
use join() function to print array or without square brackets or commas.
You can print a list without brackets and without commas. Use the string. join() method on any separator string such as ' ' or '\t' . Pass a generator expression to convert each list element to a string using the str() built-in function.
You can remove comma from string in python by using string's replace() method.
Number_list = [1, 2, 3, 4, 5]
Print(*Number_list, sep="") # empty quote
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