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
到{"Would you like to enter two more words" is == y
,如果no == Good bye!
只是迭代器来迭代和重复这个过程。有关详细信息,请参阅参考链接http://www.pythonlearn.com/html-008/cfbook006.html
只需将all代码放入循环中,只要
repeat
(初始化为“y”保持等于“y”)就迭代:相关问题 更多 >
编程相关推荐