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
ip = input('i/p:').replace('-', '')
i/p:step = int(input())
ip_cap = [i.upper() for i in ip][::-1]
ans = ''
for i in range(1, len(ip_cap) + 1):
if i % step == 0 and ip_cap[i-1] != ip_cap[-1]:
ans += ip_cap[i - 1] + '-'
else:
ans += ip_cap[i - 1]
print(ans[::-1])
Comments
Leave a comment