{:5_91:}
s1 = 'ass hello world'
def rev_string(s1):
s1 = s1.split()#返回的是字符串列表
s = []
foreach in s1:
s.append(each[::-1])
return ' '.join(s)
print(rev_string(s1)) s1 = 'ass hello world'
def rev_string(s1):
s1 = s1.split()#返回的是字符串列表
s = []
foreach in s1:
s.append(each[::-1])
return ' '.join(s)
print(rev_string(s1)) 不是说可以领鱼币吗 为什么,我这个没有输出呀?求解答 本帖最后由 shigure_takimi 于 2017-12-5 09:38 编辑
def reverse_string(string):
s = string.split(' ')
newS = [''.join(list(reversed(word))) for word in s]
print(' '.join(newS))
# 把s, newS代入print,变成:
def reverse_string2(string):
print(' '.join([''.join(list(reversed(word))) for word in string.split(' ')]
))
reverse_string('This is an example!')
reverse_string2('This is an example!')
string="This is an example!"
def reverse_string(s):
lst = s.split(' ')
for i,v in enumerate(lst):
lst = v[::-1]
return lst
看看 def reverse_string(string):
lis = string.split()
lis1 = []
for i in lis:
lis2 = []
for j in i:
lis2.insert(0,j)
lis1.append(''.join(lis2))
return ' '.join(lis1)
string = 'This is an example!'
print(reverse_string(string))
排序 1 学习
页:
1
[2]