Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
733 B
2
Indexable
Never
def read_integers(n):
    integers = []
    for i in range(n):
        num = int(input(f"Enter integer {i+1}: "))
        integers.append(num)
    return integers

def display_sorted_numbers(numbers):
    negatives = []
    zeros = []
    positives = []
    
    for num in numbers:
        if num < 0:
            negatives.append(num)
        elif num == 0:
            zeros.append(num)
        else:
            positives.append(num)
    
    for num in negatives:
        print(num)
    
    for num in zeros:
        print(num)
    
    for num in positives:
        print(num)

if __name__ == "__main__":
    n = int(input("Enter the number of integers: "))
    integers = read_integers(n)
    display_sorted_numbers(integers)
Leave a Comment