You can get rid of the error by using the below-mentioned way:-
And the reason you are getting that error is in Python 3, strings are Unicode, but when transmitting on the network, the data needs to be bytes strings instead. So... a couple of suggestions:
The first thing you can use is c.sendall() method instead of c.send() to prevent possible issues where you may not have sent the entire msg with one call.
For literals, add a 'b' for bytes string: c.sendall(b'Thank you for connecting')
For variables, you need to encode Unicode strings to byte strings (see below)
Below is the code which will work both on Python 2.0 as well as Python 3.0:-
output = 'Thank you for connecting'
c.sendall(output.encode('utf-8'))
To know more about this you can have a look at the following video tutorial:-
To Learn what is python and python applications then visit this Data Science with Python.
Wanna become an Expert in python? Come & join our Python Certification course