Search code examples
pythonstringlistint

Convert a list of integers to string


I want to convert my list of integers into a string. Here is how I create the list of integers:

new = [0] * 6
for i in range(6):
    new[i] = random.randint(0,10)

Like this:

new == [1,2,3,4,5,6]
output == '123456'

Solution

  • There's definitely a slicker way to do this, but here's a very straight forward way:

    mystring = ""
    
    for digit in new:
        mystring += str(digit)