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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -