Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

LoveMathFermat

  • 3 years ago

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.

  • This Question is Closed
  1. MicroBot
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    if something in somethingelse: do this

  2. LoveMathFermat
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  3. MicroBot
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    or if '_' not in word: etc etc

  4. LoveMathFermat
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    woops! that simple! Thanks!

  5. MicroBot
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    let me know if it works

  6. LoveMathFermat
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes! it works! Thanks MicroBot

  7. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy