+ 1

How do i solve this problem from code coach?

This is the question: Write a program to take a number as input, and output a list of all the numbers below that number, that are a multiple of both, 3 and 5. Sample Input 42 Sample Output [0, 15, 30] This the code I've written: x = int(input()) #your code goes here o = [i for i in range(x) if x%15 == 0] print(o) But this code is printing an empty list. How to fix this? Pls help.

11th Dec 2020, 5:03 PM
Aditya
Aditya - avatar
6 Antworten
+ 6
Aditya , should be i % 15 == 0, instead of x % 15 == 0. Look at the code. https://code.sololearn.com/caUdB22NbDSz/?ref=app
11th Dec 2020, 5:10 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 5
correct x = int(input()) under = [i for i in range(x) if i % 5 ==0 and i % 3==0] print(under)
24th Jul 2021, 9:02 PM
Hugues Rodrigue Tha Andela
Hugues Rodrigue Tha Andela - avatar
+ 1
Thank you so much THEWHITECAT
11th Dec 2020, 5:19 PM
Aditya
Aditya - avatar
+ 1
Aditya , you are welcome 🐱
11th Dec 2020, 5:19 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
x = int(input()) #your code goes here list=[i for i in range(x) if i % 15 == 0] print(list)
27th Jun 2021, 8:00 PM
Eduards
0
Question: Write a program to take a number as input, and output a list of all the numbers below that number, that are a multiple of both, 3 and 5. Sample Input 42 Sample Output [0, 15, 30] Solution: x = int(input()) #1.Get integer input from user allnos=[15*i for i in range(50) if 15*i<x] #Multiples of 3 AND 5 are multiples if 15 print(allnos) #printing comprehension
3rd Jun 2021, 2:32 AM
Shubhang