我现在有一句话:​​His lips are soft and his heart is soft.​​,你能用程序打乱顺序并完成做题的要求吗?

Python列表、字符串的应用——连词成句_python

注意​​I​​要大写,其他的暂不考虑。

我把代码放出来,大家看看:

from random import shuffle
a = input('请输入一个英文句子:').split(' ')
if a[0] != 'I':
a[0] = a[0].lower()
b = list(a[len(a) - 1])
c = b[len(b) - 1]
d = ''.join(b)
list(b[len(b) - 1]).pop()
b.pop()
b = ''.join(b)
a.pop()
e = []
for i in a:
e.append(i)
e.append(b)
shuffle(e)
print('连词成句是:',end = ' ')
for i in e:
print(i,end = ',')
print('(%s)' % c)

主要是列表和字符串的知识。