1incorrect = 0
2max_tries = 3
3choices = ['red', 'green', 'yellow']
4
5while incorrect < max_tries:
6 user_input = raw_input()
7 if user_input not in choices:
8 incorrect += 1
9 else:
10 rest_of_the_code(user_input)
11 incorrect = 0
12
13if incorrect == max_tries:
14 sys.exit(1)