The code:
class Car:
y = 0
x = 0
x_miles = y / 5280
y_miles = x / 5280
direction = 0
speed = 100
fps = speed * 1.467
Cords = {x}, {y}
Cords_miles = x_miles, y_miles
def driving(self):
drv = 'start'
while drv != 'stop':
if Car.direction == -270:
Car.direction = 90
elif Car.direction == 270:
Car.direction = -90
elif Car.direction == -180:
Car.direction = 180
drv = input('Say W(Forward), S(Stop), A(TurnLeft), D(TurnRight), C(GetCords): ').lower
if drv == 's':
print('this never gets executed, as well as the elifs statements after')
else:
print('this always gets executed')
the problem is that when I call the function and then enter an input, for example, if I give it the letter s, it skips to the else statement immediately. Here's the output if I enter s:
Say W(Forward), S(Stop), A(TurnLeft), D(TurnRight), C(GetCords): s
this always gets executed
I cannot seem to fix it, so it would be great if someone could help!
CodePudding user response:
You are missing brackets after you .lower
. As you can read here, without the brackets you are just setting a reference to the lower method but do not actually call it.