Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

I'm working on the very first iterative problem in PS03. I'm not sure if what I've started is remotely close to what it should be, but here's my code nonetheless: http://dpaste.com/590997/ Useful answers much appreciated. Getting "it's just wrong" with a snippet of code and no explanation is not helpful to me.

OpenStudy (anonymous):

The big problem... your for loop isn't going to iterate. The return statement on line 8 is going to hit on your first time through the loop... returning either 1 or 0 (when the find function returns 0 or -1); and the function will end. Even clearing that hurdle doesn't help much: you're iterating over each character in your target string (for s in target), but you're not using the change to alter the test conditions... so if you ran through the sequence, you'd either get a result of 0 (key not found) or len(target) -- the number of characters in the target string (because you increased the counter every time through the loop). To compare.... http://dpaste.com/591132/

OpenStudy (anonymous):

Thanks! This has helped out a lot.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Breathless: Spooky witch but cute
3 hours ago 3 Replies 0 Medals
Arriyanalol: help
3 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 3 Medals
Jaded012023: Please tell me what you all think of this song
6 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
6 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!