Now I am looking for the best way to reverse the digits in an integer. For instance x = 12345 should become y = 54321.
sneekula 969 Nearly a Posting Maven
Recommended Answers
Jump to PostWhen I first looked at this problem, I thought it would be very simple routine stuff. To my surprise this thing is loaded with programming possibilities.
# reverse integer digit by digit, the long way ... x = 12345 x_string = str(x) # "12345" x_list = list(x_string) …
Jump to PostYou need to fill in the defaults to get a better feeling for slicing:
str1 = "madam" begin = 0 # default is 0 end = len(str1) # end is exclusive, default is length of string step = -1 # - sign --> from the end in …
All 7 Replies
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
sneekula 969 Nearly a Posting Maven
Ene Uran 638 Posting Virtuoso

Mouche
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
jrcagle 77 Practically a Master Poster
ghostdog74 57 Junior Poster
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.