Print number in ascending order which contains 1 , 2 and 3 in their digits . | convert all numbers to strings ; check if each number in the list has 1 , 2 and 3 ; sort all the numbers ; Driver Code
def printNumbers ( numbers ) : NEW_LINE INDENT numbers = map ( str , numbers ) NEW_LINE result = [ ] NEW_LINE for num in numbers : NEW_LINE INDENT if ( '1' in num and '2' in num and '3' in num ) : NEW_LINE INDENT result . append ( num ) NEW_LINE DEDENT DEDENT if not result : NEW_LINE INDENT result = [ ' - 1' ] NEW_LINE DEDENT return sorted ( result ) ; NEW_LINE DEDENT numbers = [ 123 , 1232 , 456 , 234 , 32145 ] NEW_LINE result = printNumbers ( numbers ) NEW_LINE print ' , ▁ ' . join ( num for num in result ) NEW_LINE