Jan-20-2024, 06:46 AM
Hey, thank you both!
The second message made me take a closer look at the output, and then try a different input that showed the source of my issue was not what I thought at first. Earlier in the code, I tried to use a replace(), to remove spaces from a text string, and since there were no errors from that line, I had thought that the process had worked, but it must not have. A closer look at the output revealed that although I thought the print had worked, it only worked until it hit one of the spaces in the string (that were not removed). The early characters did print out, as I had noticed, but the error code wasn't because the index command didn't work with the variable, but because it had actually been fed the first space in the text string, and therefore failed to find that character in the list of alpha characters. I'll need to revisit the attempt to remove spaces from the string. The problem (which didn't generate an error immediately) was from this line:
lower_msg.replace(" ", "")
although it didn't reproduce correctly here with copy/paste,
in the compiler it actually looks like:
lower_msg.replace(__old:" ", __new"")
Since it added the other part itself, and it didn't generate any codes, I incorrectly assumed, it must have worked. It probably did exactly what I had asked, but not what I thought I had asked it to do. A good mistake to experience, just because there were no errors, doesn't mean that it did exactly what you thought it did.
The second message made me take a closer look at the output, and then try a different input that showed the source of my issue was not what I thought at first. Earlier in the code, I tried to use a replace(), to remove spaces from a text string, and since there were no errors from that line, I had thought that the process had worked, but it must not have. A closer look at the output revealed that although I thought the print had worked, it only worked until it hit one of the spaces in the string (that were not removed). The early characters did print out, as I had noticed, but the error code wasn't because the index command didn't work with the variable, but because it had actually been fed the first space in the text string, and therefore failed to find that character in the list of alpha characters. I'll need to revisit the attempt to remove spaces from the string. The problem (which didn't generate an error immediately) was from this line:
lower_msg.replace(" ", "")
although it didn't reproduce correctly here with copy/paste,
in the compiler it actually looks like:
lower_msg.replace(__old:" ", __new"")
Since it added the other part itself, and it didn't generate any codes, I incorrectly assumed, it must have worked. It probably did exactly what I had asked, but not what I thought I had asked it to do. A good mistake to experience, just because there were no errors, doesn't mean that it did exactly what you thought it did.