Answer:
The program is as follows:
word = input("Enter a word: ")
if word:
if len(word) <= 4:
word = word[::-1]
else:
word = word[0]+word[1]+word[-2]+word[-1]
print(word)
else:
print('empty!')
Step-by-step explanation:
This gets input for word from the user
word = input("Enter a word: ")
If input is not empty
if word:
This checks if the length is less than or equal to 4 characters
if len(word) <= 4:
If yes, this reverses the word
word = word[::-1]
If otherwise,
else:
This gets the first, second, second to last two characters
word = word[0]+word[1]+word[-2]+word[-1]
Print the new string
print(word)
Print empty, if input is empty
else:
print('empty!')