Split three-digit integer to three-item list of each digit in Python -
I'm new to Python, what I have to do is, the three digit integer like Any help in this will be highly appreciated. You can convert the number to a string, then iterate over the string, and each character Convert back to an integer: Or, as F. correctly indicates below, use: 634 , And divides it, so this three-item list becomes, i.e.
points = [6, 3, 4]
& gt; & Gt; & Gt; [6, 3, 4]
& gt; & Gt; & Gt; Map (int, str (634)) # Python 2 [6, 3, 4]> gt; & Gt; & Gt; List (map (int, str (634)) # Python 3 [6, 3, 4]
Comments
Post a Comment