Prerequisite Exam Error

Hello, I did my test today. And I checked all my scripts before submitting.

There are no problems at that time, but after I submit it, the autocorrection said it’s wrong.

I don’t know what is the problem,does anyone who have the same situation like me??

The code is down here. Do you know what the problem is??


Hi @bbaekddo100,

welcome to our community.

If you run your script the command below, does it work?


If not, could you try replacing the first line of your code with “#! /bin/bash” instead of “#! /bin/sh” ?

Hmm, it still works, (I didn’t change my script)

Hi @bbaekddo100,

You posted your question a while ago, and I see it is still not answered.
I investigated it a bit, and I found the following issues:
The #!/bin/bash and #!/bin/sh commands are working differently, and the automated test uses the bash.

Furthermore, during the test, the parameters are given as program arguments and not as user input. Thus, you might fail with the read command. Somehow, I could only evaluate the given program argument ($1) once; therefore, I always store it in a global variable before performing multiple evaluations.

A third issue is that you declare the list by itself, but in bash, you should use the following declaration:
declare -a words=("string1" "string2" "string3")

I hope you will find it useful to debug your code.

1 Like