##### NEED HELP WITH NUMBER SORTER
 NEED HELP WITH NUMBER SORTER Paul_Choi06 Unladen Swallow Posts: 4 Threads: 4 Joined: May 2020 Reputation: May-30-2020, 01:26 AM (This post was last modified: May-30-2020, 01:26 AM by Paul_Choi06.) Hi, I am trying to make a number sorter. I wish for the user to enter numbers and then the program will put in order from least to greatest. My problem is that when I press play there is a huge blank space in before it lists the numbers that have been sorted. Also, this code does not work with two or three and beyond digit numbers. ```blocked_n = [' ', ','] n = input('Please enter numbers for sorting: ') for word in n: if word in blocked_n: print('') n = n.replace(word, '') sort_n = sorted(n) print(sort_n)`````````Output:Please enter numbers for sorting: 9, 5, 7, 0, 3, 1 ['0', '1', '3', '5', '7', '9']`````` Reply deanhystad So-and-so of the Yard Posts: 2,362 Threads: 11 Joined: Feb 2020 Reputation: May-30-2020, 02:06 AM (This post was last modified: May-30-2020, 02:06 AM by deanhystad.) You are not sorting numbers. You are sorting strings. That is why it doesn't appear to work for numbers with 2 or more digits. To sort numbers you need to convert the strings to numbers. Your code to get the numbers is odd and it is not doing what you think it does. Python has commands for splitting a string into tokens based on a delimiter (str.split). If you want commas and spaces between the numbers I would pick comma as the delimiter. To convert the strings to numbers you use int(str) or float(str). Both of these ignore leading or trailing spaces, but they do not like commas. The print('') is causing the blank space between you input and output. Reply BitPythoner Silly Frenchman Posts: 36 Threads: 0 Joined: May 2020 Reputation: May-30-2020, 02:20 AM (This post was last modified: May-30-2020, 02:45 PM by BitPythoner.) You are looping using `for`, and consequently have a giant space. Additionally, as you are using input by itself, it defealts to string. Use int() to convert your input. Reply

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020