Problem sending string with Python to Arduino through serial port I want to send string 50 to Arduino through serial port, the Arduino UNO seems it communicates with port COM25 but it doesnt receive the string properly: 

import serial # if you have not already done so

ser = serial.Serial('COM25') 
ser.baudrate = 9600
ser.write(b'50')  
ser.close()  


Btw Arduino code is correct I checked it with other serial com programs. How can I fix the above code?
The AVR Arduinos (Uno, Nano, Mega) have auto-reset function. At opening of USB connection the circuit around USB resets the MCU. After reset the bootloader waits a second for a new upload. If the upload doesn't happen the bootloader starts the current sketch.

The serial.Serial() command in python opens the USB connection. With that the Arduino is reset and waits in bootloader while you send the data. The data doesn't arrive in your sketch. Add a two seconds wait time after Python's serial.Serial().