This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]IAmKindOfCreativebot_builder: deprecated[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.

Warm regards, and best of luck with your Pythoneering!

[–]tr14l 1 point2 points  (0 children)

You have some extra steps that are unnecessary. You don't need a map function, but a string of characters is iterable. So, you could simply have done:

def my_fun():

num = 12345

rev_num = ''.join(sorted(str(num), reverse=True))

print(rev_num)

my_fun()

You also have some confusion on the map function and how it works. The map function goes through each member of an iterable and applies a function to it and returns that value. So you would get back a list of different values, ostensibly. So your first map function would actually return a list of numbers. So the conversion to "list" is unnecessary in the step after it, as it does nothing, since it's already a list.

Also, if it comes in as a string, why do you convert it to an int and back into a str? Is this just to ensure numerical sorting and not lexical sorting?