i want to split up a raw_input into many integers like this
TheString = raw_input
>>>12345678
and then spit up TheString to integers
d1 = 1
d2 = 2
d3 = 3
d4 = 4
d5 = 5
d6 = 6
d7 = 7
d8 = 8
I tried to find it but it did not work what the others suggested.
Thank you in advance.
Don't use different variable names for each digit. You can convert the string to a list of integers and index the list to get each digit.
>>> s = "314159" # or s = raw_input()
>>> d = map(int, s)
>>> d[0]
3
>>> d[1]
1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.