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,520 points
672 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
• 58,090 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
• 69,210 points

Related Questions In Python

0 votes
1 answer

How to convert each list item into string in a column of data frame. ?

Hey, To split a string you can use ...READ MORE

answered Feb 5, 2020 in Python by Roshni
• 10,520 points
684 views
0 votes
1 answer

How to convert list to string

To convert list to string in Python ...READ MORE

answered Feb 9, 2022 in Python by Dev
• 6,000 points
292 views
0 votes
0 answers

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

How can I convert a list to ...READ MORE

Sep 21, 2022 in Python by Samuel
• 460 points
339 views
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,830 points
445 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,023 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,409 views
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
• 58,090 points
752 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
• 58,090 points
648 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP