I want to print a list in python without the square brackets. It is always coming printing like [“a”,”b”,”c”]
Announcement! Career Guide 2019 is out now. Explore careers to become an AI/ ML Engineer or Data Scientist!
print (', '.join(name))
It will simply take all the elements in a list(name), and joins them with ‘, ’
Because join() is a method of a string type object, and joins lists that are made of string type objects. If your list is consisted of integers, it would not work. For example, you would have to do str() on all elements of your list to do a join() on it.
You can try this for arrays:
print(*names, sep = ', ')
This is what I use
You can use looping to do this. This is not the best way but it is a possible way so I posted it:
for name in names:
print(names[index], end=", ")
index += 1
print(", ".join(str(x) for x in name))
Can you tell what is * for ?
If you want to print the elements of the list or array without using loops, then you can use the '*' symbol to print the list elements in a single line with space.
Could you please post all your error logs? Please post your workaround.
You can read array from the users like this:
And you can directly print the array as follows:
There are many other ways to read and write an array. Do you want any particular way to do this?
Hey @abhijmr.143, you can print array integers ...READ MORE
ou are using Python 2.x syntax with ...READ MORE
You need to import the NumPy module ...READ MORE
Python doesn't have a native array data ...READ MORE
suppose you have a string with a ...READ MORE
You can also use the random library's ...READ MORE
colors = ['red', 'green', ...READ MORE
can you give an example using a ...READ MORE
You can use '\n' for a next ...READ MORE
calculate square root in python
>>> import math ...READ MORE
Already have an account? Sign in.