Вопрос задан 14.11.2023 в 23:29. Предмет Информатика. Спрашивает Борисенко Фёдор.

ПИТОН. Вам подается на вход последовательность целых чисел, в которой каждое число идет на новой

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

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Завяликова Ксения.

a = []

while True:

   s = input()

   if s == '.':

       break

   a.append(int(s))

print(a)

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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) ```

0 0

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

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

Последние заданные вопросы в категории Информатика

Задать вопрос