How to convert list to string

+1 vote

How can I convert a list to a string using Python?

Aug 13, 2018 in Python by bug_seeker
• 15,310 points
35 views

2 answers to this question.

0 votes

By using ''.join

list1 = ['1', '2', '3'] str1 = ''.join(list1)

Or if the list is of integers, convert the elements before joining them.

list1 = [1, 2, 3] str1 = ''.join(str(e) for e in list1)

answered Aug 13, 2018 by Priyaj
• 56,160 points
0 votes
  1. mylist = [1, 2, 3] 
  2. ‘’.join(map(str, mylist))
  3. ==> 123
  4.  
  5. mylist = [1, 2, 3, 'a', 'b', c]
  6. ''.join(map(str, mylist))
  7. ==> 123abc
answered Aug 21, 2018 by Omkar
• 67,140 points

Related Questions In Python

0 votes
1 answer

Python - convert string to list

states.split() will return ['Alaska', 'Alabama', 'Arkansas', 'American', 'Samoa', ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,810 points
40 views
0 votes
1 answer

How to convert string into epoch time?

you are passing the parsed datetime object to ...READ MORE

answered Sep 21, 2018 in Python by SDeb
• 12,520 points
76 views
0 votes
1 answer

How to convert a Unicode string to string

It can be done in the following ...READ MORE

answered Oct 16, 2018 in Python by SDeb
• 12,520 points
65 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010 ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 56,160 points
80 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 135 views
+4 votes
6 answers
0 votes
1 answer

Python - convert string to list

try states.split() this would help. READ MORE

answered Jul 20, 2018 in Python by Priyaj
• 56,160 points
52 views
0 votes
1 answer

How to split a string into a list?

You can use the function  text.split() This should be ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 56,160 points
34 views