Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
486 B
2
Indexable
Never
input_str = input()
output_list = []

for substring in input_str.split(','):
    src, dest, mobilenumber = substring.split(':')
    src_first_two = src[:2]
    dest_last_two = dest[-2:]
    sum_digits = sum(int(digit) for index, digit in enumerate(mobilenumber) if index % 2 == 0)
    passenger_no = len(output_list) + 1
    output_str = f"{src_first_two}{dest_last_two}{sum_digits}{passenger_no}"
    output_list.append(output_str)

output_str = ','.join(output_list)
print(output_str)