import sys
keyword = raw_input("enter a keyword ").lower()
key_phrase = raw_input("enter a key phrase").lower()
key_phrase_length = len(key_phrase)
character_position = []
for character in keyword:
if character in "abcdefghijklmnopqrstuvwxyz":
position = "abcdefghijklmnopqrstuvwxyz".find(character) + 1
character_position.append(position)
cycle = -1
new_keyword = ""
if len(keyword) < len(key_phrase):
while len(keyword) < len(key_phrase):
cycle += 1
if cycle >= len(keyword):
cycle = 0
new_keyword = new_keyword + keyword[cycle]
sys.stdout.write(new_keyword[cycle])
上面是我的代碼,當輸入關鍵字如「cat」和關鍵短語如「computing」時,代碼應該將「cat」的字母打印到計算單詞的長度。然而,這個運行到一個循環爲什麼我的代碼會陷入無限循環?