Answer to Question #343519 in Python for Varun

Question #343519

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


1
Expert's answer
2022-05-22T18:14:25-0400
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])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS