Computer Science Canada friggin program |
Author: | qwertyuiop [ Mon Dec 18, 2006 6:38 pm ] | ||
Post subject: | friggin program | ||
i am trying to have the user enter a word then i want to create a new string that has substituded the letters of that word to underscores.. i just cant figure it out can someone look through this code and point out my problem please
|
Author: | TokenHerbz [ Mon Dec 18, 2006 6:48 pm ] | ||
Post subject: | |||
Well your code
Look at your "i" var, it will only go up to the length of the puzzle word. If you are trying to get a specific char variable, which is what i think you'r trying to do, then i suggest you look at chr and ord. If you want to do it the easy way. Make 2 vars. one for your word, and the other created with "_" for each spot in the word. |
Author: | Clayton [ Mon Dec 18, 2006 9:56 pm ] | ||
Post subject: | |||
He did in fact do that TokenHerbz.
Now, what you need to do is instead of checking the index of your for loop, you need to check the character value is (using the function ord()). That way you can check the value of each character in your "puzzle" string, then, if a character is a letter, add an underscore to puzzle2, otherwise, add the character to puzzle2. |