I'm trying to figure out how to split data received from a socket. I have the sockets working and I can get the data correctly but I now want to split the data retrieved and obtain the last string. Here is what I'm trying(data is the data received from the socket)
split = data.split(' ')
print split
print split[-1]
But when I try it it wont work for some reason. Like lets say I have the string received as "test test1" I want to get test1.
data? Your example should work as long as it can be split correctly (assumes the string not to be zero etc.)print split[-1], what does it show?