Skip to content

Instantly share code, notes, and snippets.

@peterldowns
Created September 27, 2013 20:45
Show Gist options
  • Save peterldowns/6734892 to your computer and use it in GitHub Desktop.
Save peterldowns/6734892 to your computer and use it in GitHub Desktop.
number = int(raw_input('Enter a number between 20 and 0: '))
# Only one of the following statements will print. If a condition
# (like "number < 20") is matched, then only that part of the block
# will run. That's what elif does. Else, if.
if number < 20:
print '%d is less than 20' % number
elif number < 10:
print '%d is less than 10' % number
elif number < 5:
print '%d is less than 5' % number
print '\n\n--------------------\n\n'
# In this case, all of the applicable conditions will be run,
# beacuse we're setting up a bunch of different comparisons
# that aren't related to eachother.
if number < 20:
print '%d is less than 20' % number
if number < 10:
print '%d is less than 10' % number
if number < 5:
print '%d is less than 5' % number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment