Skip to main content
added 153 characters in body
Source Link

Basic Advice

  • We don't normally use comparison operators for booleans like you do in

      while guessed==False : 
    

    Instead, we can use

      while not guessed :
    

    (same as the code that you have) or

      while guessed :
    

    (opposite to the code you have - runs while true)

    The reason for this is that doing another comparison is simply an overkill. The statement is going to evaluate to a boolean anyway, so why not use the one that you already have, and invert if necessary? To check if something is true, comparison actually does nothing, and in this example negation (with not) is slightly faster and easier to read than what you have.

  • Either: Put spaces around your all of your operators for readability, or stick to not using spaces around any of your operators - don't mix and match like you do in this program. Do note however that although it is good to be consistent, it is even better to stick with standards and simply put spaces around all of your operators.

Comment

Your program seems to be based on good, solid principles, and has been (for the most part) nicely implemented.

Basic Advice

  • We don't normally use comparison operators for booleans like you do in

      while guessed==False : 
    

    Instead, we can use

      while not guessed :
    

    (same as the code that you have) or

      while guessed :
    

    (opposite to the code you have - runs while true)

    The reason for this is that doing another comparison is simply an overkill. The statement is going to evaluate to a boolean anyway, so why not use the one that you already have, and invert if necessary? To check if something is true, comparison actually does nothing, and in this example negation (with not) is slightly faster and easier to read than what you have.

  • Either: Put spaces around your all of your operators for readability, or stick to not using spaces around any of your operators - don't mix and match like you do in this program.

Comment

Your program seems to be based on good, solid principles, and has been (for the most part) nicely implemented.

Basic Advice

  • We don't normally use comparison operators for booleans like you do in

      while guessed==False : 
    

    Instead, we can use

      while not guessed :
    

    (same as the code that you have) or

      while guessed :
    

    (opposite to the code you have - runs while true)

    The reason for this is that doing another comparison is simply an overkill. The statement is going to evaluate to a boolean anyway, so why not use the one that you already have, and invert if necessary? To check if something is true, comparison actually does nothing, and in this example negation (with not) is slightly faster and easier to read than what you have.

  • Either: Put spaces around your all of your operators for readability, or stick to not using spaces around any of your operators - don't mix and match like you do in this program. Do note however that although it is good to be consistent, it is even better to stick with standards and simply put spaces around all of your operators.

Comment

Your program seems to be based on good, solid principles, and has been (for the most part) nicely implemented.

Source Link

Basic Advice

  • We don't normally use comparison operators for booleans like you do in

      while guessed==False : 
    

    Instead, we can use

      while not guessed :
    

    (same as the code that you have) or

      while guessed :
    

    (opposite to the code you have - runs while true)

    The reason for this is that doing another comparison is simply an overkill. The statement is going to evaluate to a boolean anyway, so why not use the one that you already have, and invert if necessary? To check if something is true, comparison actually does nothing, and in this example negation (with not) is slightly faster and easier to read than what you have.

  • Either: Put spaces around your all of your operators for readability, or stick to not using spaces around any of your operators - don't mix and match like you do in this program.

Comment

Your program seems to be based on good, solid principles, and has been (for the most part) nicely implemented.