Answer to Question #227338 in Python for srikanth

Question #227338
Multiples of 3

You are given 

N inputs. Print the numbers that are multiples of 3.

Input

The first line of input is an integer 

N. The next N lines each contain an integer as input.

Explanation

In the given example, there are 

6 inputs. 1, 2, 3, 5, 9, 6. The numbers 3, 9, 6 are multiples of 3.

So, the output should be 

3
9
6
Sample Input 1
6
1
2
3
5
9
6
Sample Output 1
3
9
6
Sample Input 2
4
1
3
6
8
Sample Output 2
3
6

1
Expert's answer
2021-08-22T00:27:19-0400
list1 = []
n = int(input('Enter no of integers here: '))
for i in range(n):
  n1 = int(input('Enter integer here: '))
  if n1 % 3 == 0:
    list1.append(n1)
for j in list1:
  print(j)

Enter no of integers here: 6
Enter integer here: 1
Enter integer here: 2
Enter integer here: 3
Enter integer here: 5
Enter integer here: 9
Enter integer here: 6
3
9
6

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS