나는 편지 바이스 반대입력 된 텍스트를 파이썬으로 변환하는 방법은 무엇입니까?
# vise versa
print ("word vise versa")
word = input("Input your text ")
new_word = ""
while word:
position = len(word) - 1
for letter in word:
new_word += letter[position]
position -= 1
print(new_word)
이고, inputed에서 새로운 단어를 구축 쓰기 프로그램을 시도 항상 내가 잘못 무슨 실수
Traceback (most recent call last):
File "4_2.py", line 9, in <module>
new_word += letter[position]
IndexError: string index out of range
가 있나요? 감사합니다.
'letter [position]'대신'word [position]'을 사용 했습니까? 또한, 이것은 단지'new_word = word [:: - 1]'인 것처럼 보입니다. – jonrsharpe
한 번 더, 어떻게'while' 루프를 깨뜨릴까요 ?? –
감사! 정말 "단어".... 루프는 휴식으로 끝났다 – luckyander