Answer to Question #234479 in Python for vijay

Question #234479

Write a program that reads a single line of input and prints the first two and last two characters of the given input and prints the asterisk character (*) in place of the remaining characters.


Explanation

For example, if the given string is message, then the first two and last two characters are me, ge. Now replacing all the remaining characters with * will give the output me***ge.


Sample Input 1

Message

Sample Output 1

Me***ge

Sample Input 2

12345

Sample Output 2

12*45


1
Expert's answer
2021-09-07T14:16:07-0400

line = input('Input line: ')

line = line.replace(line[2:-2], '*'*len(line[2:-2]), 1)

print(line)



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