This code always returns a ValueError when it is not supposed to: i = rest.rfind('?') Error: ValueError: need more than 0 values to unpack rfind is not supposed to generate an erro, just return -1. Any ideas?