I have the feeling that I've either forgotten (or never knew) some basic Python built-in or something, but in case I haven't, what's the best way to convert a list of integers to a string?  Here are two I've come up with. Although intListToString2() is the more Pythonic, intListToString1() is the faster, unless intList is very long, or has big integers.

def intListToString1(intList):
    s = ""
    for n in intList:
        s = s + str(n)
    return s
   
def intListToString2(intList):
    lst = []
    for y in intList:
        lst.append(str(y))
    return "".join(lst)

But have I missed something?

Dick Moores

           ================================
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to