Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
486 B
1
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)