Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 64M

Problem type

Given a list of n numbers, sort them and output them one per line from smallest to largest.

Input Specification

The first line of the input contains a positive integer n no greater than 100, the number of numbers to follow.

Each line after will have a single positive integer less than 32000.

Output Specification

Output the numbers in sorted order from smallest to largest, one per line.

Sample Input

Copy
4
4
3
2
1

Sample Output

Copy
1
2
3
4

Comments


  • 0
    DeedleP  commented 13 days ago edit 9

    Hi, does anyone know why my code isn't working? It works fine on my machine.

    Copy
    n = input().split()
    for i in range(len(n)):
        n[i] = int(n[i])
    n.sort()
    for i in n:
        print(f'{i}')
    

    • 0
      4EVr_Working  commented 12 days ago

      You have to take the first line of input N (the amount of numbers you will have to consider). After that, your should take the inputs in a for loop and then sort.


  • 0
    21georgeburge  commented 28 days ago edited

    very good problem!


    • 0
      21georgeburge  commented 28 days ago

      i did notmean to comment this, sorry


  • -4
    someoneanony  commented on Oct. 18, 2024, 10:06 p.m. edited

    Sorry I don't understand why does it mark it as wrong? It works on pycharm perfectly fine, with my examples and the ones shown above as well. In addition, the input("whatever") part is empty, which is the only difference I've encountered thus far. Any tips/reasons? Thanks in Advance --> Python


    Copy
    n = int(input())
    lista = []
    for x in range(n):
        lista.append(input())
    
    lista = sorted(lista)
    
    for each in lista:
        print(each)
    

    • 0
      Sam629566  commented on Oct. 20, 2024, 3:17 p.m.

      Sorting strings is not the same as sorting integers. If you look at your clipped output, you see that your output becomes:

      Copy
      1
      10
      2
      3
      ...

      Read the values in the list as integers, and your code should pass. Hope this helps!


  • 1
    granpanis222  commented on Sept. 25, 2020, 11:16 p.m.

    Why I'm I getting this?: Test case #1: IR (✗✗✗✗✗✗✗✗✗✗) [0.019s, 8.28 MB] (0/100) Test case #2: IR (✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗✗) [0.018s, 8.28 MB] (0/200)


    • 11
      Kirito  commented on Sept. 26, 2020, 2:47 a.m.

      This is a line-by-line checker, so you get a checkmark if you get the line correct, and an x if you get the line wrong.

      Running your code locally gives the error message AttributeError: 'int' object has no attribute 'sort'.