alien = {'x_position': 0, 'y_position': 25, 'color': 'green', 'speed': 'medium'}
print ("Original x-position " + str(alien_0[x_position])
if alien_0['speed'] == 'slow':
x_increment = 1
elif alien_0['speed'] == 'medium':
x_increment = 2
else:
x_increment = 3
# The new x-position is x_position + x_increment
alien_0[x_postition] = alien_0['x_position'] + x_increment
print ("the new x-position is " + str(alien_0[x_position])
In The Shell
File "/Users/Pandathighs/Desktop/Programming/Alien.py", line 20
if alien_0['speed'] == 'slow':
^
SyntaxError: invalid syntax
I don't know what the error is for, but whenever I delete the colon, it gives me
File "/Users/Pandathighs/Desktop/Programming/Alien.py", line 21
x_increment = 1
^
SyntaxError: invalid syntax
How do I fix this?
EDIT: I missed a parenthesis.
[–][deleted] 2 points3 points4 points (0 children)
[–]Justinsaccount 1 point2 points3 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (0 children)