我试图通过大写数组中的每个字符来操作一个单词,但是当涉及到一个具有两个相同字符的单词时,它会使它们都大写而不是一个。不是一个只想学习 python 的程序员。预先感谢!
answer = raw_input("What is your word? ")
x = 0
answerWord = ''.join(answer)
while (x < len(answer)):
if (answerWord[x] != answerWord[x].upper()):
letter = answerWord.replace(answer[x], answer[x].upper())
print letter
x = x + 1
What is your word? boot
Boot
bOOt
bOOt
booT
What is your word? crazy
Crazy
cRazy
crAzy
craZy
crazY