如何将列表中的字符串合并到变量中?[Python]

如何将列表中的字符串合并到变量中?[Python],python,list,Python,List,我想这可能就是你的意思: word =("Enter a word: ") listword = list(word) def final(): while True: index = int(input("Enter an index: ")) if index > len(word) - 1: input print "Try again" continue else:

我想这可能就是你的意思:

word =("Enter a word: ")
listword = list(word)

def final():
    while True:
        index = int(input("Enter an index: "))
        if index > len(word) - 1:
           input print "Try again"
            continue
        else:
            break
    while True:
            letter = input("Enter a letter: ")
            if len(letter) == 1:
                break
            else:
                continue
    listword[index] = letter
    print listword
while True:
    final()
word=input(“输入一个单词:”)
listword=列表(word)
尽管如此:
index=int(输入(“输入索引:”)

如果索引,我如何将列表中的字母作为一个字符串打印,而不是在列表中单独打印?
word = input("Enter a word: ")
listword = list(word)

while True:
    index = int(input("Enter an index: "))
    if index <= len(word) - 1:
        break
    print("Try again")

while True:
    letter = input("Enter a letter: ")
    if len(letter) == 1:
        break

listword[index] = letter
print("".join(listword))