Открыть боковую панель
parsadanovvv
Yard Sale Helper
Коммиты
c59e111d
Коммит
c59e111d
создал
Май 17, 2026
по автору
parsadanovvv
Просмотр файлов
Загрузить новый файл
владельцы
Изменения
1
Скрыть пробелы
Построчно
Рядом
main.py
0 → 100644
Просмотр файла @
c59e111d
# Read the list of item prices (space-separated numbers)
prices
=
input
()
# Read the seller's phone number
phone
=
input
()
# TODO: Split the prices string and convert to numbers
int_prices
=
[
int
(
num
)
for
num
in
prices
.
split
()]
# TODO: Calculate the product of the first two prices
first_two_prices_sum
=
int_prices
[
0
]
*
int_prices
[
1
]
# Print the product of first two prices
print
(
first_two_prices_sum
)
# TODO: Check if phone number matches XXX-XXX-XXXX format
# Hint: A valid phone has exactly 12 characters with dashes at positions 3 and 7
def
validate_phone_manual
(
phone
):
# Проверяем длину
if
len
(
phone
)
!=
12
:
return
False
# Проверяем позиции дефисов
if
phone
[
3
]
!=
'-'
or
phone
[
7
]
!=
'-'
:
return
False
# Разбиваем на части
parts
=
phone
.
split
(
'-'
)
# Должно быть 3 части
if
len
(
parts
)
!=
3
:
return
False
# Проверяем, что все части — цифры и имеют нужную длину
return
(
len
(
parts
[
0
])
==
3
and
parts
[
0
].
isdigit
()
and
len
(
parts
[
1
])
==
3
and
parts
[
1
].
isdigit
()
and
len
(
parts
[
2
])
==
4
and
parts
[
2
].
isdigit
()
)
# Print "Valid" or "Invalid" for the phone number
if
validate_phone_manual
(
phone
)
==
True
:
print
(
"Valid"
)
else
:
print
(
"Invalid"
)
\ Нет новой строки в конце файла
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать