Serial connection between Arduino and raspberry pi won't work

I have hooked up a raspberry pi and arduino nano via usb cable and have been trying to get them to communicate, but I am having problems reading the number that the arduino sends to the pi.
The print function on the python will say '31', but when I try to check if it equals that number is says False.

Python code:

import serial

ser = serial.Serial('/dev/ttyUSB0')

while True:
	serial_input = ser.readline()
	print(serial_input)
	if(serial_input == '31'):	
		print('number received')
		break;

Arduino code:

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

void loop() {
	char data[50];
	sprintf(data, "%02X", '1');
	Serial.println(data);
	delay(1000);
}

I think the problem is that what you receive CONTAINS the characters '31' and also some other characters - perhaps just a linefeed. Hence the variable serial_input is not exactly '31'. I have forgotten how Python checks for characters contained in a string - is it with IN?

...R