pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
second = word[1]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
print new_word
else:
print 'empty'
我需要这个循环,并且当用户使用低位或大写字母的任意组合输入“退出”时。 (qUit,QUIT,quIT,即。)
任何提示都表示赞赏。感谢。
答案 0 :(得分:1)
尝试这样的事情:
pyg = 'ay'
original = raw_input('Enter a word:')
while original and original.strip().upper() != 'QUIT':
# loop body
if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
second = word[1]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
print new_word
else:
print 'empty'
# read again, for next loop
original = raw_input('Enter a word:')
答案 1 :(得分:0)
试试这个
pyg = 'ay'
while True:
original = raw_input('Enter a word:')
if original.upper() == 'QUIT':
break
if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
second = word[1]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
print new_word
else:
print 'empty'
break
答案 2 :(得分:-1)
new_word = new_word [1:]
##它更好! #to拆分第一个单词nom ='AlassaneAli'
mylist = list()
代表我的名字:
mylist.append(i)
对于范围内(len(mylist)):
print(mylist[a])
print(mylist [1:])