<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_shard_by_num(self, shard_num):
 """ get_shard_by_num returns the shard at index shard_num. Keyword arguments: shard_num -- The shard index Returns a redis.StrictRedis connection or raises a ValueError. """

        if shard_num < 0 or shard_num >= self.num_shards():
            raise ValueError("requested invalid shard# {0}".format(shard_num))

        return self._shards[shard_num]