
ПИТОН. Вам подается на вход последовательность целых чисел, в которой каждое число идет на новой
строке. Заканчивается последовательность точкой. Прочитайте такую последовательность и выведите список, содержащий её элементы.Sample Input 1:123.Sample Output 1:[1, 2, 3]

Ответы на вопрос

a = []
while True:
s = input()
if s == '.':
break
a.append(int(s))
print(a)



Answer in detail. PYTHON. You are given a sequence of integers, in which each number goes on a new line. The sequence ends with a dot. Read such a sequence and output a list containing its elements. Sample Input 1: 1 2 3. Sample Output 1: [1, 2, 3]
To solve this problem, you need to use a loop to read the input until you encounter a dot. You can use the input() function to read one line at a time, and append the integer value of the line to a list. You can use the int() function to convert a string to an integer, and the break statement to exit the loop when you see a dot. Here is a possible code that implements this logic:
```python # create an empty list to store the input numbers numbers = []
# loop until the input is a dot while True: # read one line of input line = input()
# check if the input is a dot if line == ".": # exit the loop break
# convert the input to an integer and append it to the list number = int(line) numbers.append(number)
# print the list of numbers print(numbers) ```


Похожие вопросы







Топ вопросов за вчера в категории Информатика









Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili