这是我的代码;
mood = 0
if mood == 5:
mood = 4
# I don't want the mood going over four下面是情绪是如何增加的;
moode = raw_input("how are you").lower()
if 'bad' in moode:
mood += 1
print ('You have said that %s times today')%(mood)问题是,如果你说了5次,她会回答‘你已经说了5次了’,但我不希望情绪超过4次?
发布于 2014-06-17 00:01:00
在递增mood之后,您需要检查它的值。
mood = 0
if 'bad' in moode:
mood += 1
if mood > 4:
mood = 4
print ('You have said that %s times today')%(name)或者就像@arsajii提到的那样-如果它已经是4或更高,不要同时递增
mood = 0
if 'bad' in moode:
if mood < 4:
mood += 1
print ('You have said that %s times today')%(name)https://stackoverflow.com/questions/24247764
复制相似问题