how to print the digits from a string from the end to the beginning separated by commas in python?
can someone please help me? my input is a list of two strings. each string is a four digits number. I need to take the two strings. and print each's digits from the end to the beginning separated by commas, but without a comma after the last digit. thanks (:
You can just concatenate the strings and use the
> s1 = '1234' > s2 = '5678' > print(','.join(s1 + s2)) '1,2,3,4,5,6,7,8'
In: two_strings = ['1234', '5678'] In: for elem in two_strings: ...: print(','.join(elem)) ...: 1,2,3,4 5,6,7,8