You are in college. Every student in your college has a unique ID on their ID Card. Unique ID contains letters, numbers, and hyphens(-). But now, your college administration wants to modify the unique ID of ID Cards. Modifications required are-
- All letters should be capitalized.
- Hyphens should come inside ID after a certain fixed length(starting from the right).
- Fixed length will be given during input.
For example-
Input:
Enter string: as4-12fgt-5hgJ
Enter length: 3
Output:
AS4-12F-GT5-HGJ
Code for ID Card in Python:
s = input('Enter string: ') n = int(input('Enter length: ')) new_s = '' for i in s: new_s = new_s+ i.upper() new_s = new_s.split('-') new_s = ''.join(new_s) result = [] for i in range(0, len(new_s), n): result.append(new_s[i:i+n]) result=result[::-1] result='-'.join(result) result=result[::-1] result=result.split('-') new_result = [] for i in result: new_result.append(i[::-1]) print('-'.join(new_result))
Output:

Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Composite Number in Python
- Greatest Among Four Numbers in Python
- Reverse the sentence in Python
- Denominations in Python
- Min and max values in an array in JavaScript
- Keyboard events in JavaScript
- Reaching Ground Floor in Python
- Number of Moves in Python
- Starks Adventure in Python
- Neutralization in Python | Assignment Expert
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- First Place in Python
- Triples with Properties in Python
- Nested list Indexing Python
- Team Points in Python
- Two words combination in Python
- ID Card in Python
- Cipher with a key in Python | Assignment Expert
- Multiple of 5 in Python
- Sandglass Star in Python
- Multiple of 3 in Python | Assignment Expert
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Sum of List Elements in Python
- All possible subsets in Python
- Names and Nicknames in Python