Question: Write a Python program which receives a string and returns a new string with the first 2 and the last 2 chars from a

Write a Python program which receives a string and returns a new string with the first 2 and the last 2 chars

Write a Python program which receives a string and returns a new string with the first 2 and the last 2 chars from a given string. If the string length is less than 2, print out an appropriate message to the user. (10 points) Sample input: Please enter a string: python Expected output: pyon Sample input: Please enter a string: py Expected output: pypy Sample input: Please enter a string: p Expected output: Your string is too short!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

mainpy 1 def processstringinputstring if leninputstring 2 2 23 4 5 6 7 return ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!