Python Forum
NEED HELP WITH NUMBER SORTER
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NEED HELP WITH NUMBER SORTER
#1
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


Messages In This Thread
NEED HELP WITH NUMBER SORTER - by Paul_Choi06 - May-30-2020, 01:26 AM
RE: NEED HELP WITH NUMBER SORTER - by deanhystad - May-30-2020, 02:06 AM
RE: NEED HELP WITH NUMBER SORTER - by BitPythoner - May-30-2020, 02:20 AM

Forum Jump:

User Panel Messages

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