How to move the first letter of a word to the end
我需要删除单词的第一个字母并将其移到末尾,例如:
1 2 | word = 'whatever' # I want to convert it to 'hateverw' |
到目前为止,我已经尝试过:
1 | word[1:] # hatever |
但我该如何将第一个字母移到末尾呢?
你可以使用:
1 | word[1:]+word[0] |
以下是我所做的:
1 2 3 4 5 | wrd = input("Give me a word:") pig = wrd[1:] + wrd[0] +"ay" print(wrd,"in Pig Latin it is:", pig.lower()) |