输入一行字符串,然后对其进行如下处理。
输入格式:
字符串中的元素以空格或者多个空格分隔。
输出格式:
逆序输出字符串中的所有元素。
然后输出原列表。
然后逆序输出原列表每个元素,中间以1个空格分隔。注意:最后一个元素后面不能有空格。
输入样例:
a b c e f gh
输出样例:
ghfecba
['a', 'b', 'c', 'e', 'f', 'gh']
gh f e c b a
in_str=input().split(" ")
new_str=[]
new_list=[]
for c in in_str:
if c!='':
new_str.append(c)#'+='与'append'不同
new_list.append(c)
new_list.reverse()
res_str=''
for c in new_list:res_str+=c
print(res_str)
print(new_str)
for i in range(len(new_list)):
if i!=len(new_list)-1:
print(new_list[i], end=" ")
else:print(new_list[i])