print "You've entered a wording system!"
print "What words do you want?"
while False:
word1 = raw_input('enter your word:')
word2 = raw_input('enter your word:')
print word1
print word2
if len(word1)>len(word2):
word_difference = len(word1) - len(word2)
print word1, "is", word_difference, "letters longer than", word2
elif len(word2)>len(word1):
word_difference = len(word2) - len(word1)
print word2, "is", word_difference, "letters longer than", word1
elif len(word1) == len(word2):
print word1, "has same number of letters as", word2
repeat = raw_input("Would you like to enter two more words?(y/n)")
if repeat == "y":
y == False
因此,如果问题要求您word1 = raw input
以及repeat = raw_input(asking fort two more words)
"Would you like to enter two more words" is == y
重复到no == Good bye!
的代码
答案 0 :(得分:0)
只需将所有代码放入循环中,只要repeat
进行迭代(初始化为" y"保持等于" y&#34 ):
print "You've entered a wording system!"
print "What words do you want?"
repeat = "y"
while repeat == "y":
word1 = raw_input('enter your word:')
word2 = raw_input('enter your word:')
print word1
print word2
if len(word1)>len(word2):
word_difference = len(word1) - len(word2)
print word1, "is", word_difference, "letters longer than", word2
elif len(word2)>len(word1):
word_difference = len(word2) - len(word1)
print word2, "is", word_difference, "letters longer than", word1
elif len(word1) == len(word2):
print word1, "has same number of letters as", word2
repeat = raw_input("Would you like to enter two more words?(y/n)")
答案 1 :(得分:0)
Just Iterator迭代并重复该过程。有关详细信息,请参阅参考链接http://www.pythonlearn.com/html-008/cfbook006.html