Raja Raja - 6 months ago 15
Python Question

convert list into string in python3

Right now I am having a list

>>> deints
[10, 10, 10, 50]


I want to print it as
10.10.10.50
. I made it as

Method 1



>>> print(str(deints[0])+'.'+str(deints[1])+'.'+str(deints[2])+'.'+str(deints[3]))
10.10.10.50


Are there any other ways we can acheivie this ?

Thank you

Answer

You can do it with:

print '.'.join(str(x) for x in deints)