Reputation: 3
Here's my code;
mood = 0
if mood == 5:
mood = 4
# I don't want the mood going over four
Here is how the mood increases;
moode = raw_input("how are you").lower()
if 'bad' in moode:
mood += 1
print ('You have said that %s times today')%(mood)
The problem is that if you say it 5 times, she replies 'you have said it 5 times' but I don't want mood to go over four?
Upvotes: 0
Views: 68
Reputation: 59601
You need to check the value of mood
after you increment it.
mood = 0
if 'bad' in moode:
mood += 1
if mood > 4:
mood = 4
print ('You have said that %s times today')%(name)
or as @arsajii mentioned - don't even both incrementing if it's already 4 or above
mood = 0
if 'bad' in moode:
if mood < 4:
mood += 1
print ('You have said that %s times today')%(name)
Upvotes: 2