-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFinalStage.py
48 lines (39 loc) · 1.04 KB
/
FinalStage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Add your Python code here. E.g.
from microbit import *
won = False
code1 = "ABAAB"
code2 = "ABBAB"
code3 = "BABBB"
def matchCode(Correct_code):
Ans_Code = ""
while len(Ans_Code) != len(Correct_code):
if button_a.get_presses():
Ans_Code += "A"
if button_b.get_presses():
Ans_Code += "B"
if Ans_Code == Correct_code:
correct = True
else:
correct = False
return correct
while not won:
display.show("1")
correct1 = matchCode(code1)
if correct1 == True:
display.show("2")
correct2 = matchCode(code2)
if correct2 == True:
display.show("3")
correct3 = matchCode(code3)
if correct3 == True:
display.scroll("You Won! Well Done!")
won = True
else:
display.show("X")
sleep(1000)
else:
display.show("X")
sleep(1000)
else:
display.show("X")
sleep(1000)