Using serial with arduino and python, cannot read propper data from adruino

The issue is with your Python code. When I run your Arduino sketch with this simple python keyboard send a message to Arduino and read the reply I can see the Arduino code you wrote echo the received message.

import serial  
import time  

ArduinoSerial = serial.Serial('COM6',115200, timeout = 2) #timeout for response on readline()
time.sleep(2) #allow time for serial port to open

while True:
 print ("enter message for Arduino")
 var = input()# get input from user
 print ("you entered", var )# print the input for confirmation
 ArduinoSerial.write(var.encode())#send to Arduino
 #read echo back from arduino to verify receipt of message
 data = ArduinoSerial.readline() #the last bit gets rid of the new-line char
 if data:
    print("received message back from Arduino")
    print (data.decode())
 time.sleep(1)