Всем привет. У меня вопрос по поводу питона. Здесь комп. игра. В моём коде машина едет всё время в одном направлении, однако должна ехать в случайном. Рандом у меня есть. В чём проблема? И да, игра ещё не доделанная. VV КОД VV
 import pygame
 from random import choice
 from random import randint 
 cordi2 = randint(10,250)
 cordi = [10,130,250]
 import time
 WIDTH = 300
 HEIGHT = 500
 FPS = 60
 WHITE = (255, 255, 255)
 RED = (241, 58, 19)
 PURPLE = (99,58,101)
 BLACK = (0, 0, 0)
 pygame.init()
 clock = pygame.time.Clock()
 screen = pygame.display.set_mode((WIDTH, HEIGHT))
 x = 130
 y = 410
 y_enemy = 0 - 70
 car = pygame.Rect(x,y,40,70)
 position = randint(1,3)
 if position == 1:
 x_enemy = 10
 elif position == 2:
 x_enemy = 130
 elif position == 3:
 x_enemy = 250
 car_img = pygame.image.load("car.bmp").convert() 
 car_enemy_img = pygame.image.load("carenemy.bmp").convert()
 car_enemy = pygame.Rect(x_enemy,y_enemy,40,70)
 SPEED = 2
 running = True
 while running:
 screen.fill(WHITE)
 for i in pygame.event.get():
 if i.type == pygame.QUIT:
 running = False
 if i.type == pygame.KEYDOWN:
 if i.key == pygame.K_LEFT:
 if car.left > 10:
 car.left -= 120
 if i.key == pygame.K_RIGHT:
 if car.left < 250:
 car.left += 120
 if car_enemy.top >= HEIGHT + 70:
 if position == 1:
 x_enemy = 10
 elif position == 2:
 x_enemy = 130
 elif position == 3:
 x_enemy = 250
 SPEED += 1
 position = randint(1,3)
 car_enemy.top = 0 - 70
 else:
 car_enemy.top += SPEED
 screen.blit(car_enemy_img, (car_enemy.left, car_enemy.top))
 screen.blit(car_img, (car.left, car.top))
 pygame.display.update()
 clock.tick(FPS)
 pygame.quit()
                                                            
                             
                         
                    
var
n, i, aon_i, k: integer;
f: boolean;
function AmountOfNumbers(n: integer): integer;
var
s: integer;
begin
s := 0;
while n > 0 do
begin
s := s + n mod 10;
n := n div 10;
end;
AmountOfNumbers := s;
end;
begin
readln(n);
for i := 0 to n do
begin
f := true;
aon_i := AmountOfNumbers(i);
for k := 2 to 9 do
f := f and (aon_i = AmountOfNumbers(k * i));
if f then writeln(i);
end;
end.
Объяснение: