20 gal is fine as long as it has some snug hide boxes and (depending on the species) substrate to burrow in.

on occasion snakes will get stressed if forced to be exposed 24/7 and go off feed.

ensure all of it's needs are met and any size cage should be fine.

also, some screen top 10 and 20 gal tanks have lids that are great for adults, but a little loose for tiny guys so make sure that is covered.