试图找出如何从我的输出中删除句点。作业的正确答案是:wa。EA。人工智能.六、六
我的输出是:wa。EA。人工智能。阿维。
我试过用rstrip删除。但那不起作用。
感谢您对这个新手python程序员的一些见解。
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the',
'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
s_sent=sent.split()
acro = ''
for word in s_sent:
if word not in stopwords:
acro=acro + str.upper(word[:2])+". "
acro=acro.rstrip('.')
print(acro)