Anonymous asked in Computers & InternetProgramming & Design · 8 months ago

This is my coding homework. What does it mean?

In your function, start with an empty result string. Write a for loop from 0 up to but not including the length of your secret word. Say you use the variable i in your for loop. Compare the character in secret_word at index i to the guess. If they’re equal, then that means the guess matches that letter in the word, so you should add the guess to the result. Otherwise, the guess does not match that letter in the word, so you should add whatever was at index i in dashes to your result.

I don't really understand what it's asking me after not including the length of the secret_word.

4 Answers

  • EddieJ
    Lv 7
    8 months ago
    Favourite answer

    It seems that you have been given more instructions than just this.  

    I'm assuming <dashes> is the name of a parameter.

    It seems if the secret word is "pumpkin" and the guess is "m" then the result of the function should be "--m----", assuming this is the first time the function is called.

    Then, if the function is called again with a guess of "p", the result would be "p-mp---".

  • Steven
    Lv 4
    8 months ago

    You have just need to use the loop that will start from i (i=0) and use (i=0, i<0, i++). I think it helpful for you. 

    Attachment image
  • Anonymous
    8 months ago

    It means you fail the assignment.

  • Anonymous
    8 months ago


    secret = "TestWords"

    guess = "Teethered"

     result = "Te-t - ---d-"

Still have questions? Get answers by asking now.