如何使用用户输入的单词创建句子

how to create a sentence using words from user input

如何使用用户输入的单词造句? 我现在有一个程序,它要求用户输入一个数字,然后根据该数字,用户必须输入一定数量的单词,然后这些单词应该组合在一起构成一个句子。 这是我目前所拥有的:

howmany = (int (input ("How many words?\n>")))
for words in range (howmany):
        words = input ("Words please:\n>")

试试这段代码,应该可以正常工作:

from __future__ import print_function

howmany = int (input ("How many words?\n>"))

words = []
for i in range (howmany):
    words.append(str(raw_input ("Words please:\n>")))

for word in words:
    print(word, end=' ')