Python Practice Lab
easyUnit 9 · Comprehensions: list, set, dict

P25. Multiples of 3 or 5

Comprehensions: list, set, dict

Read n. Use a list comprehension to build the list of numbers from 1 to n that are divisible by 3 or by 5. Print the list and its sum.

Input Format

  • Line 1: n

Output Format

  • Line 1: Multiples: <list>
  • Line 2: Sum: <value>

Constraints

  • 1 ≤ n ≤ 100

Sample Test Cases

Sample 1
Input
15
Output
Multiples: [3, 5, 6, 9, 10, 12, 15]
Sum: 60
Sample 2
Input
2
Output
Multiples: []
Sum: 0

Submitting checks 2 sample cases and 3 hidden test cases.

Hints

Saved
Custom 1

This is your own input, so Run will show what your program prints but can't say whether it's correct.