我正在尝试创建一个程序,该程序在输入“”之前要求输入单词。然后程序将打印出一个句子中的所有单词。然后用每个单词的第一个字母做一个首字母缩略词。我正在使用python。示例如下所示。先谢谢你。很快就要交了。:)
sentence = []
acrostic = []
word = -1
while word:
sentence.append(word)
acrostic.append(sentence[0].upper())
print(sentence)
print("-- {}".format(acrostic))
Word: A
Word: cross
Word: tick
Word: is
Word: very
Word: evil
Word:
A cross tick is very evil
-- ACTIVE
python 3.8或更高版本
输出:
python 3.6和3.7
python 3.5或更早版本
也许你在找这样的东西:
输入:
sentence
中,并将其第一个字母保存在acrostic
(word[0]
而不是sentence[0]
)对于输出:
" ".join(sentence)
"".join(acrostic)
给予
相关问题 更多 >
编程相关推荐