#4. 编写函数,从键盘输入一字符串,把其中的各个字符颠倒,标点符号不颠倒,例如,‘I enjoy reading!’,
#经过函数调用后变为‘gnidaer yojne I!’,
#注意:输入字符串的中间没有标点符号,而最后一个字符可以是标点符号。
#coding=utf-8
def diandao(s):
bdfh = '!,;:?"\'、,.'
bdfh=list(bdfh)
l=list(s)
if l[-1] not in bdfh:
l=l[::-1]
else:
temp=l.pop()
l=l[::-1]
l.append(temp)
print("颠倒后的字符串为:")
for i in l:
print(i,end='')
s=input('请输入一串字符串:')
diandao(s)