Коммит c59e111d создал по автору parsadanovvv's avatar parsadanovvv
Просмотр файлов

Загрузить новый файл

владельцы
# 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.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать