I want to convert the integers from 0 to 9 to strings. I was able to do it by manually transforming each number like this:
str(1) = a
str(2) = b
... All the way untill 9. However, this is slow and the code doesn't look very pythonic. I would like to see a faster to code solution, such as putting all these numbers into a list and then transforming each element inside the list to a string. I know that to make said list I should do it like this:
a = range(0,10)
However, I don't know how to transform the ints inside the list to strings. Thanks in advance for your help.
You can use map()
to apply str()
to each value in your array:
a = map(str, range(0, 10))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With