Help. Arduino + Python Ambilight doesn't work

I'm begginer at arduino and coding and trying to make ambilight for my monitor. I've started this project a few days ago and can't get any results.
There's no errors in Python or Arduino IDE, LED works correct, if i command it manual. I think trouble in reading COM data, but i can't solve it.
There's Arduino code:

#include <FastLED.h>

#define NUM_LEDS 71
#define PIN 6      

CRGB leds[NUM_LEDS];

String state;
String LastData = "";

int ActiveLed = 0;

int r = 0;
int g = 0;
int b = 0;

void setup() {
   FastLED.addLeds <WS2812, PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
   FastLED.setBrightness(10);
   Serial.begin(9600);
   Serial.setTimeout(20);
}

void loop()
{
  String receivedData = Serial.readString();
  
  if(LastData != Serial.readString())
  {
    state = LastData;
  }
  
  switch(state[0])
  {
    case 'r':
      state.remove(0);
      r = state.toInt();
    case 'g':
      state.remove(0);
      g = state.toInt();      
    case 'b':
      state.remove(0);
      b = state.toInt();  
    case 'l':
      state.remove(0);
      ActiveLed = state.toInt();        
  }
  

 
  leds[ActiveLed] = CRGB(255, 255, 255);
  leds[ActiveLed] = CRGB(r, g, b);
  leds[5] = CRGB(0, 0, 255);
    
  LastData = Serial.readString();
  FastLED.show();
}

And Python:

import serial
import time
import pyautogui

time.sleep(2)

ser = serial.Serial("COM4", 9600)
ser.timeout = 0.02

i = 0

color = pyautogui.pixel(100, 200)

l = 0
r = 0
g = 0
b = 0


while True:
	for i in range(71):
		if i < 21:
			color = pyautogui.pixel(3800, round(2120 / 21 * i))
		elif i > 50:
			color = pyautogui.pixel(40, round(2120 / (71 - 51) * (71 - i)))
		else:
			color = pyautogui.pixel(round(3800 / 32 * (i - 20)), 40)	
		
		ser.write(('r' + str(color[0])).encode('utf-8'));
		ser.write(('g' + str(color[1])).encode('utf-8'));
		ser.write(('b' + str(color[2])).encode('utf-8'));
		ser.write(('l' + str(i)).encode('utf-8'))

what do you hope for your code to do?

@surokada to transmit and receive the pixel values and index try and simplify things a little. Instead of messing around with strings use the values directly. Color is a tuple of three values so if we add the index all we need to transmit is four byte values

At the Python side

while True:
    for i in range(71):
        if i < 21:
            color = pyautogui.pixel(3800, round(2120 / 21 * i))
        elif i > 50:
            color = pyautogui.pixel(40, round(2120 / (71 - 51) * (71 - i)))
        else:
            color = pyautogui.pixel(round(3800 / 32 * (i - 20)), 40)
        
        data=list(color)	
        data.append(i)
        ser.write(data)

At the Arduino each of the four bytes we receive in the 'buffer' array represents r,g,b,l respectively. Here again we don't mess with strings or switch/case we use the value of the bytes we receive.

byte buffer[4];
byte r;
byte g;
byte b;
byte l;

void setup() {
Serial.begin(9600);
}

void loop() {
while (Serial.available () > 0){

int bytesRead = Serial.readBytes(buffer,4);

r=buffer[0];
g=buffer[1];
b=buffer[2];
l=buffer[3];


}
}

Verify this with a few tests and add in the code for the leds.

If the packet write at the Python end is too fast you may need a small delay.

Thank you!!! It worked! You are the best!