How to convert all objects(elements) of list to str | Sololearn: Learn to code for FREE!
+ 2

How to convert all objects(elements) of list to str

Hi, i want to print catalogues: catalogue = 'history' index = list(range(1,21) def print_catalogues(summ): print(catalog + index) print_catalogues(summ) I need convert list to str(). How do it right?

5th Mar 2017, 9:59 AM
Vladimir Pavlychev
Vladimir Pavlychev - avatar
4 Respostas
+ 1
catalogue = 'history' index = list(range(1,21) def print_catalogues(summ): print(catalog + str(index)) print_catalogues(summ) #covert to string by str(_____)
5th Mar 2017, 10:03 AM
vishnu
vishnu - avatar
0
Vishnu, thanks for your answer. I must test your code on my PC;)
5th Mar 2017, 10:08 AM
Vladimir Pavlychev
Vladimir Pavlychev - avatar
0
there are IFs like int() #int of str() #string of etc... chr() float() any thing can be converted to string for others it may not happen int('hello') will return a value error
5th Mar 2017, 10:18 AM
vishnu
vishnu - avatar
0
maybe it not possible with list(range(1,21))?
5th Mar 2017, 6:43 PM
Vladimir Pavlychev
Vladimir Pavlychev - avatar