[Test Development Engineer Python Interview] How to convert elements in a list into strings?

Analysis of python interview questions:

Topic: How to convert elements in a list into strings? , Such as L = [1, 2, 3, 5, 6], how to get '12356'?

#coding=utf-8
#Date:2020-05-17 1:24
#Version:V1.0.0
#Author:honghao.jhh

'''
面试题目:L = [1, 2, 3, 5, 6,7,8],如何得出 '1235678'?

'''
stringA=''
L = [1,2,3,5,6,7,8]
for i in L:
	stringA= stringA+str(i)
print 'Result is:' + stringA
print 'Result type is:' + str(type(stringA))

The code running results are as follows:

Result is:1235678
Result type is:<type 'str'>

 

Guess you like

Origin blog.csdn.net/jinhoward/article/details/106168399