Posted: Thu Mar 17, 2011 12:14 pm Post subject: Re: counting the number of words in a string
yes but then what do i do to change it from being always false
Sponsor Sponsor
Insectoid
Posted: Thu Mar 17, 2011 12:22 pm Post subject: RE:counting the number of words in a string
code:
if words(i..x)=" "
You're specifying a range here. I dunno how Turing would handle this, but it looks like 'If this section of this string is a space' rather than 'if this character of this string is a space'.
For example, if our string is 'Hello world', and x is 6, Turing will compare 'Hello '* to ' '. See how it isn't equal?
*This may vary depending on weather or not Turing zero-indexes strings. I don't remember.
Tony
Posted: Thu Mar 17, 2011 12:23 pm Post subject: RE:counting the number of words in a string
You change it to something that has a chance at being true at least sometimes.
The problem here is that you are asking (in a way of writing code) for a computer to do something that is different from what you _think_ you are asking. It might be subtle and you might have to print out some actual values to see what's going on. The hint is that it's always false, your job is to figure out why.