Expected Expression Error on MacOS Ventura 13.0

I am new to coding, and recently I used python to generate a starting/begging code for me. Sadly when I pasted this into Apple Swift, it shows up with "Expected Expression". Does anyone know how to fix this?


# Initialize Pygame
pygame.init()

# Set up the screen
screen_width = 800
screen_height = 600
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("Loading Screen")

# Define the colors for the gradient
              colors = [(255, 204, 0), (255, 102, 0), (255, 0, 0)]
               
              # Define the rectangle for the gradient
              gradient_rect = pygame.Rect(0, 0, screen_width, screen_height)
               
              # Draw the gradient
              for i in range(screen_height):
                color = tuple(map(lambda x, y: int(x + (y - x) * i / screen_height), colors[0], colors[-1]))
              pygame.draw.line(screen, color, (0, i), (screen_width, i))
               
              # Update the screen
              pygame.display.flip()
               
              # Set the time for the loading screen
              loading_time = 5000 # 5 seconds
               
              # Start the loading screen
              loading_screen_start = pygame.time.get_ticks()
               
              # Main loop
              while True:
                # Check for events
              for event in pygame.event.get():
                if event.type == pygame.QUIT:
                pygame.quit()
              exit()
               
              # Check if the loading screen is over
              if pygame.time.get_ticks() - loading_screen_start >= loading_time:
                # End the loading screen
              break
               
              # Quit Pygame
              pygame.quit()

Python and Swift are different programming languages. As such, Swift Playgrounds cannot understand the Python code you pasted since Swift Playgrounds only knows how to work with Swift code, and not Python. If you'd like to learn how to code using Swift, the Swift Playgrounds app has plenty of supporting guides you can create from the main screen of the app that you can use as a starting point, as shown in the attached screenshot.

Expected Expression Error on MacOS Ventura 13.0
 
 
Q