If I have an integer like x = 12345, how do I separate that into individual integers 1, 2, 3, 4, 5?
sneekula 969 Nearly a Posting Maven
Recommended Answers
Jump to PostIf you wanted to use the digits of an integer, you could convert to a string like mawe suggested and then use the indexed string elements ...
x = 12345 s = str(x) print s[0] # 1 print s[1] # 2 print s[2] # 3 print s[4] …
All 3 Replies
mawe 6 Junior Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
sneekula 969 Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.