Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I need to join a list of items. Many of the items in the list are integer values returned from a function; i.e.,

myList.append(munfunc())

How should I convert the returned result to a string in order to join it with the list?

Do I need to do the following for every integer value:

myList.append(str(myfunc()))

Is there a more Pythonic way to solve casting problems?

1 Answer

0 votes
by (106k points)

You can use the below-mentioned code to join a list of items with different types as a string in Python:-

a=[1,2,3] 

b=[str(x) for x in a] 

print b

Related questions

0 votes
4 answers
0 votes
4 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...