How to make a string into an array or an array into a string in Python

I will write how to make a string into an array in Python, and how to make an array into a string. I look forward to working with you.

When making a character string an array.

s = 'AIUEO'
print(list(s)) 
print([i for i in s])
#['Ah', 'I', 'U', 'e', 'O']And output

When making an array a character string.

print(''.join(['Ah', 'I', 'U', 'e', 'O']))
print(*['Ah', 'I', 'U', 'e', 'O'], sep='')
#Aiueo and output

When making an array of numbers into a character string.

n = [1, 2, 3, 4, 5]
print(''.join([str(i) for i in n]))
print(*[str(i) for i in n], sep='')
#12345 and output
#If join is int, an error will occur, so I am converting to str

that's all. Thank you very much.

Recommended Posts

How to make a string into an array or an array into a string in Python
How to embed a variable in a python string
How to convert / restore a string with [] in python
[Python] How to expand variables in a character string
How to slice a block multiple array from a multiple array in Python
How to convert an array to a dictionary with Python [Application]
How to swap elements in an array in Python, and how to reverse an array.
"Cython" tutorial to make Python explosive: How to parse an Enum class defined in C ++ code into a Python Enum.
How to make a Python package (written for an intern)
[Python] How to make a class iterable
[Python] How to invert a character string
How to get a stacktrace in python
[Introduction to Python] How to output a character string in a Print statement
How to get a string from a command line argument in python
How to create a heatmap with an arbitrary domain in Python
How to clear tuples in a list (Python)
How to create a JSON file in Python
How to notify a Discord channel in Python
[Blender x Python] How to make an animation
[Python] How to draw a histogram in Matplotlib
How to make Python Interpreter changes in Pycharm
Insert an object inside a string in Python
I want to color a part of an Excel string in Python
How to write a string when there are multiple lines in python
How to format a list of dictionaries (or instances) well in Python
How to sort by specifying a column in the Python Numpy array.
Parse a JSON string written to a file in Python
I want to embed a variable in a Python string
Try to make a Python module in C language
How to write string concatenation in multiple lines in Python
Explain in detail how to make sounds with python
How to make an interactive CLI tool in Golang
How to turn a .py file into an .exe file
Make a bookmarklet in Python
How to make a Python package using VS Code
How to create an image uploader in Bottle (Python)
How to develop in Python
How to execute a command using subprocess in Python
How to input a character string in Python and output it as it is or in the opposite direction.
What do you like about how to convert an array (list) to a string?
[Python] How to make an adjacency matrix / adjacency list [Graph theory]
A story about how to specify a relative path in python.
How to use the __call__ method in a Python class
How to import a file anywhere you like in Python
How to transpose a 2D array using only python [Note]
[Python] How to write an if statement in one sentence.
How to define multiple variables in a python for statement
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to check if a value exists in an enum
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python
Python learning basics ~ How to output (display) a character string? ~
I tried to make a stopwatch using tkinter in python
[Python] How to output a pandas table to an excel file
I want to make input () a nice complement in python
How to get a quadratic array of squares in a spiral!
How to connect the contents of a list into a string
How to make a Japanese-English translation
How to write a Python class
[Python] How to do PCA in Python