Please convert the following java code to Python so that the Python program executes successsfully passing the test cases 


import java.util.*;

import java.util.stream.Collectors;


public class Hello{

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);

        Set<Integer> numset=new TreeSet<>();;

        while(sc.hasNextLine()){

            List<Integer> numlist=Arrays.stream(sc.nextLine().trim().split("\\s+")).map(Integer::valueof).collect(Collectors.toList());

            numSet.addAll(numList);

        }

        for(int num:numSet){

            System.out.print(num+" ");

        }

    }

}


Solution:

numset=[]

while True:

    try:

        numList=list(map(int,input().split()))

        numset.extend(numList)

    except:

        break

print(*sorted((set(numset))))