Answer to Question #343956 in Python for Varun

Question #343956

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-23T10:19:36-0400

It has to be split from the end. So:

print("Enter the id")
s = input()


print("Enter group length")
n = input()


s = s.replace("-", "")
letters = list(s)
print(letters)
for i in range (len(s)-3,0,-3):
    print(i)
    slist.insert(i,"-")
s = ''.join(letters)
print(s)

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