How can i use internal iteration within function in python? -


i need code run :

pp = ["first", "second", "third"] sum(d d in pp) 

i error:

typeerror: unsupported operand type(s) +: 'int' , 'str' 

i guess there lazy evaluation. please me this?

thank you!

sum() buildin function default start 0. takes numbers , return total. not allowed string. so, above error. rather, can join list using ''.join() function.

like :

pp = ["first", "second", "third"] sum = ''.join(pp) print(sum) 

output :

firstsecondthird 

Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -