This is my code below, it is saying that there is an error but i cannot understand the error (the ‘^’ is pointing at the ‘:’ of the elif statement): File “”, line 47 elif: ^ SyntaxError: invalid syntax
” print (“there are 27 sticks”)
JavaScript
x
52
52
1
sticks = 27
2
3
player1 = True
4
Ai = False
5
6
print ("there are 27 sticks, pick the last one !")
7
8
print("1")
9
print("2")
10
print("3")
11
12
while player1 == True:
13
14
inp = int(input("Enter the number of sticks you want to take: "))
15
16
if inp == 1:
17
inp = "1: 1 stick taken"
18
sticks = sticks -1
19
print (sticks)
20
player1 = False
21
Ai = True
22
elif inp == 2:
23
inp = "2 sticks taken"
24
sticks = sticks - 2
25
print (sticks)
26
player1 = False
27
Ai = True
28
elif inp == 3:
29
inp = "3 sticks taken"
30
sticks = sticks - 3
31
print (sticks)
32
player1 = False
33
Ai = True
34
else:
35
print("Invalid input!")
36
37
38
while Ai == True:
39
if sticks == 7:
40
InpAi = 3
41
sticks = sticks - InpAi
42
print (sticks)
43
player1 = True
44
Ai = False
45
elif:
46
print ("")
47
48
else:
49
''
50
51
52
Advertisement
Answer
JavaScript
1
13
13
1
while Ai == True:
2
if sticks == 7:
3
InpAi = 3
4
sticks = sticks - InpAi
5
print (sticks)
6
player1 = True
7
Ai = False
8
elif: # <= add condition here if any otherwise remove that line :)
9
print ("")
10
11
else:
12
''
13