Python Program
Write a python program to print the following output.
Input
The first line contains a string S representing a unique id.
The second line contains an integer N representing group length.
Output
The output should be a single string representing the new unique id.
Sample Input1
2-4A0r7-4k
3
Sample Output1
24-A0R-74K
str_id = input()
num = int(input())
str_id = str_id.replace('-','')
new_str_id = []
while str_id:
new_str_id.insert(0, str_id[-num:])
str_id = str_id[:-num]
print('-'.join(new_str_id))
Comments
Leave a comment