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

Hi fellow OCW students, I have a question about the Hangman game homework. http://pastebin.com/2mhjAqZC here is my function for checking if there's more guesses to go. What it does is that it goes through every string in 'inter' to see if there's '_' . So, if there's none of them, it means you've guessed everything and you won. However, my question is that my code seems to be too long. Are there more efficient ways to check if there's a specific character that I'm looking for in my string.

OpenStudy (microbot):

if something in somethingelse: do this

OpenStudy (anonymous):

'inter' is the string of your guesses on a word. So, it changes from '_ _ _ _ ' to something like '_ _ s _"

OpenStudy (microbot):

or if '_' not in word: etc etc

OpenStudy (anonymous):

woops! that simple! Thanks!

OpenStudy (microbot):

let me know if it works

OpenStudy (anonymous):

Yes! it works! Thanks MicroBot

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
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 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!