Created
April 3, 2016 17:05
-
-
Save jon003/06a344e95d96f5fe2fc9b4d5d41a6ee3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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