Skip to content

Instantly share code, notes, and snippets.

@jon003
Created April 3, 2016 17:05
Show Gist options
  • Save jon003/06a344e95d96f5fe2fc9b4d5d41a6ee3 to your computer and use it in GitHub Desktop.
Save jon003/06a344e95d96f5fe2fc9b4d5d41a6ee3 to your computer and use it in GitHub Desktop.
# from /u/coding2learn
#Create these Lists:
#[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0]
results = [num for num in range(-10,1)] # hey, i learned you don't even need a conditional!
#print(results)
#A list of all consonants in the sentence 'The quick brown fox jumped over the lazy dog'
teststring = 'The quick brown fox jumped over the lazy dog'
vowels = ['a','e','i','o','u',' ']
results = [letter for letter in teststring if letter.lower() not in vowels]
#print(results)
#A list of all the capital letters (and not white space) in 'The Quick Brown Fox Jumped Over The Lazy Dog'
import string
teststring = 'The Quick Brown Fox Jumped Over The Lazy Dog'
results = [letter for letter in teststring if letter in string.uppercase]
#print(results)
#A list of all square numbers formed by squaring the numbers from 1 to 1000.
results = [num**2 for num in range(1,1001)]
#print(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment