Skip to content

Instantly share code, notes, and snippets.

@bbookman
Created December 26, 2018 21:39
Show Gist options
  • Save bbookman/949b8fd32f432d4ee7feb1010fa82e47 to your computer and use it in GitHub Desktop.
Save bbookman/949b8fd32f432d4ee7feb1010fa82e47 to your computer and use it in GitHub Desktop.
Python List Comprehension: Find all of the numbers from 1-1000 that are divisible by 7
'''
Find all of the numbers from 1-1000 that are divisible by 7
'''
div7 = [n for n in range(1,1000) if n % 7 == 0]
print(div7)
@sumanth-hs27
Copy link

sol = [ n for n in range(1,1001) if n%7 == 0 ]

@shaik23032001
Copy link

res=[y for y in range(1,1000) if y%7==0]

@AldebaranHere
Copy link

solution = [a for a in range(1,1000+1) if a % 7 == 0]

@alizeyang228
Copy link

res = [n for n in range(1,1001) if n % 7 ==0)

@vgauss07
Copy link

vgauss07 commented Aug 9, 2024

div_by_7 = [num for num inn range(1001) if num % 7 == 0]
print(div_by_7)

@onrcn-tnrkl
Copy link

list= [i for i in range(1,1001) if i%7==0]

@Akelvino
Copy link

list1 = [x for x in range(1001) if x%7==0]
print(list1)

@prabhakarvats1117
Copy link

num = print([n for n in range(1,1001) if n%7==0])

output = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210, 217, 224, 231, 238, 245, 252, 259, 266, 273, 280, 287, 294, 301, 308, 315, 322, 329, 336, 343, 350, 357, 364, 371, 378, 385, 392, 399, 406, 413, 420, 427, 434, 441, 448, 455, 462, 469, 476, 483, 490, 497, 504, 511, 518, 525, 532, 539, 546, 553, 560, 567, 574, 581, 588, 595, 602, 609, 616, 623, 630, 637, 644, 651, 658, 665, 672, 679, 686, 693, 700, 707, 714, 721, 728, 735, 742, 749, 756, 763, 770, 777, 784, 791, 798, 805, 812, 819, 826, 833, 840, 847, 854, 861, 868, 875, 882, 889, 896, 903, 910, 917, 924, 931, 938, 945, 952, 959, 966, 973, 980, 987, 994]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment