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()
答案 0 :(得分:0)
我想这可能就是你的意思了:
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))