+ 3

How so you display list objects as a string (python)

How would you make a list such as: [d, o, g] be displayed as: dog if you could post a solution that was for any length of list that would be most helpful. :)

15th Feb 2018, 5:16 PM
Zack
Zack - avatar
3 Answers
15th Feb 2018, 5:25 PM
Youssef Ouamou
Youssef Ouamou - avatar
+ 8
The join method as proposed by Yousef is the correct way. There is another way also. lis=['d','o','g'] print(*lis,sep='') print(''.join(lis))
15th Feb 2018, 7:27 PM
Louis
Louis - avatar
+ 3
Good question, I have never really thought about it and now that I think of it, knowing this could have really helped me in my recent codes.
15th Feb 2018, 5:19 PM
Jax
Jax - avatar