Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

In Python, pass is how you indicate that nothing happens; you shouldn't just put None on a line on its own. Alternatively, note that:

if x:
    pass
else:
    y()

is the same as:

if not x:
    y()

except that the latter is much neater.


You are right that the repeated int is bad form. You might find Asking the user for input until they give a valid responseAsking the user for input until they give a valid response useful in helping you refactor to make number an int as early as possible.

In Python, pass is how you indicate that nothing happens; you shouldn't just put None on a line on its own. Alternatively, note that:

if x:
    pass
else:
    y()

is the same as:

if not x:
    y()

except that the latter is much neater.


You are right that the repeated int is bad form. You might find Asking the user for input until they give a valid response useful in helping you refactor to make number an int as early as possible.

In Python, pass is how you indicate that nothing happens; you shouldn't just put None on a line on its own. Alternatively, note that:

if x:
    pass
else:
    y()

is the same as:

if not x:
    y()

except that the latter is much neater.


You are right that the repeated int is bad form. You might find Asking the user for input until they give a valid response useful in helping you refactor to make number an int as early as possible.

Source Link
jonrsharpe
  • 13.9k
  • 2
  • 36
  • 62

In Python, pass is how you indicate that nothing happens; you shouldn't just put None on a line on its own. Alternatively, note that:

if x:
    pass
else:
    y()

is the same as:

if not x:
    y()

except that the latter is much neater.


You are right that the repeated int is bad form. You might find Asking the user for input until they give a valid response useful in helping you refactor to make number an int as early as possible.