# Secret code not fetching in this text. @ip1 test

**URL:** https://forum.codecrafters.io/t/secret-code-not-fetching-in-this-text-ip1-test/3625
**Category:** Challenges
**Tags:** challenge:shell
**Created:** [December 23, 2024, 11:14am UTC](https://forum.codecrafters.io/t/secret-code-not-fetching-in-this-text-ip1-test/3625 "2024-12-23T11:14:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![SubratBihari](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/subratbihari/32/3660_2.png) [@SubratBihari](https://forum.codecrafters.io/u/SubratBihari)
#### Post date: [December 23, 2024, 11:14am UTC](https://forum.codecrafters.io/t/secret-code-not-fetching-in-this-text-ip1-test/3625/1 "2024-12-23T11:14:19Z")

</div>

![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/7/77c51d3a67c72b47f4044f6bbf5fb854d504e537.png)  
python code below. i tried many possible ways but not fetching secreat code for this test. please check and update me where i am wrong here.

```auto
def find_in_path(param):
    path = os.environ['PATH']
    print("Path: " + path)
    print(f"Param: {param}")
    for directory in path.split(":"):
        for (dirpath, dirnames, filenames) in os.walk(directory):
            if param in filenames:
                return f"{dirpath}/{param}"
    return None

 def main():

    while True:
        sys.stdout.write("$ ")
        sys.stdout.flush()
        # user_input = input()

        # Wait for user input
        arg, command = input().split(" ")
        
        match command.split(" "):
            case ["exit", "0"]:
                exit(0)
            case ["echo", *cmd]:
                print(" ".join(cmd))
            case ["type", *cmd]:
                match cmd:
                    case ["echo" | "exit" | "type"]:
                        print(f"${cmd[0]} is a shell builtin")
                    case _:
                        location = find_in_path(cmd[0])
                        if location:
                            print(f"${cmd[0]} is {location}")
                        else:
                            print(f"${" ".join(cmd)} not found")
            case _:
                
                #print(f"{command}: command not found")
                if os.path.isfile(command.split(" ")[0]):
                    os.system(command)
                else:
                    print(f"Hello {command}! The secret code is {arg}.")

```

---

<div class="post-metadata">

### Author: ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)
#### Post date: [December 23, 2024, 2:32pm UTC](https://forum.codecrafters.io/t/secret-code-not-fetching-in-this-text-ip1-test/3625/3 "2024-12-23T14:32:26Z")

</div>

Hi @SubratBihari, it’s not the correct approach to hardcode the output:

```auto
print(f"Hello {command}! The secret code is {arg}.")

```

The goal is to locate `my_exe` on the system and execute it with the provided arguments.

---

<div class="post-metadata">

### Author: ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)
#### Post date: [December 29, 2024, 9:48pm UTC](https://forum.codecrafters.io/t/secret-code-not-fetching-in-this-text-ip1-test/3625/5 "2024-12-29T21:48:30Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)
#### Post date: [January 3, 2025, 9:49pm UTC](https://forum.codecrafters.io/t/secret-code-not-fetching-in-this-text-ip1-test/3625/6 "2025-01-03T21:49:16Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
