+ 4
Your script works. You are probably just having a challenge running it in SoloLearn.
SoloLearn does not allow the program to ask questions to the user while the program is running. You have to supply all inputs in the pop-up box before the script runs. In that box, you put all your inputs on separate lines like this:
Jerry
23
Ed
Joy
123456789
123456789
Then it will produce the output.
+ 1
I think you're trying to print the values that are stored in the variables a, b, c, etc. If so, you are trying to print them just as a string (inside the quotes). To print variables, they should not be in quotes. The characters inside quotes are taken as a string. I hope the modified code attached helps you.
https://sololearn.com/compiler-playground/cgC8iYnyNOm4/?ref=app
or you can concatenate them like you did in the line 15
0
Helle
0
iy is good
0
import pygame
import random
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Car Crash Game")
# Colors
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
# Load car image
car_image = pygame.Surface((50, 100))
car_image.fill(BLUE)
# Create a class for obstacles
class Obstacle:
def __init__(self):
self.width = 50
self.height = 100
self.x = random.randint(0, WIDTH - self.width)
self.y = random.randint(-150, -100)
def move(self):
self.y += 5
def draw(self):
pygame.draw.rect(screen, RED, (self.x, self.y, self.width, self.height))
# Game loop variables
clock = pygame.time.Clock()
car_x, car_y = WIDTH // 2, HEIGHT - 120
obstacles = []
score = 0
running = True
# Game loop
while running:
screen.fill(WHITE)
for event in pygame.event.get():
if event.type == pygame.QUIT:
runnin
0
What error in this