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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -