How to print only one ouput on the console instead of all possible paths

You can make change in this code

Hey, i have made changes to the code.