0
Can you help in writing Python code?
The program is fed a sequence of integers divisible by 7, each number on a separate line. The end of the sequence is any number not divisible by 7. Write a program that outputs the members of a given sequence. Input format The program is fed a sequence of numbers, each number on a separate line. Output format The program should output the members of this sequence. Sample Input 1: 49 2401 4809 0 2 10 100 Sample Output 1: 49 2401 4809 0
4 ответов
+ 8
Адилет Мнашов ,
it's a bit difficult to understand the task description clearly.
? is the number of input values fixed to e.g. 7 values, or can it be any other number of values ?
+ 7
Адилет Мнашов ,
we can help you, if you have done a try that you should link here.
+ 1
items = [ ]
while True:
n = int ( input ( ) )
if n == 7:
print ( items )
break
else:
items.append ( n )
I've tried my best but still can't get the final code that I have to accomplish
+ 1
Адилет Мнашов
To check divisibility by 7 use modulus operator (%) like n % 7 == 0
If it is then append in items
If not then append last item and break loop