Use List comprehension to create a list of all numbers between 1 and 50 that are divisible by 3. program
Answers
Answered by
0
Answer:
Normally you might try: numbers = [] for x in range(100): if x % 3 == 0: numbers.append(x) You can include an if statement in the list comprehension to conditionally include items. To create a list of numbers between 0 and 100 that are divisible by three, here is a way using a list comprehension: numbers = [x for x in range(100) if x % 3 == 0]
Similar questions