不要看到我在这里做错了什么。
在创建第一个变量之后的新行上:
创建一个名为new_word的新变量,并将其设置为word,first和pyg的串联。
将new_word设置为等于从第一个索引一直到new_word结尾的切片。使用[1:len(new_word)]
执行此操作。
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
print original
else:
print 'empty'
word = original.lower()
first = word[0]
new_word = word + first + pyg
newer_word = [0:len(new_word)]
答案 0 :(得分:0)
以下是解决方案:
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
print original
else:
print 'empty'
word = original.lower()
first = word[0]
new_word = word + first + pyg
newer_word = new_word[1:len(new_word)] """ u were forgetting to which word it should slice and as mentioned u should slice from 1st index not 0 index """
print newer_word