My code is very long. Is there a way to shorten it?

23 hours ago 1
ARTICLE AD BOX

I was writing code to generate a random area for a game I'm making with python. Currently, the code looks like this:

import random as rand zone = rand.randint(1, 20) subzone = rand.randint(1, 10) if zone < 5: zone = "water" subzone = "" elif zone < 11: zone = "forest" subzone = "" elif zone < 18: zone = "plain" if subzone == 1: subzone = "" elif subzone < 5: subzone = " with deer" elif subzone < 8: subzone = " with cows" else: subzone = " with horses" else: zone = "stone" if subzone < 4: subzone = " with marble" elif subzone < 7: subzone = " with iron" else: subzone = "" print(zone + subzone)

I was wondering if there is an easier way to do the same thing that doesn't require so much code, especially if the system will eventually become more and more complicated. I'm fairly new to python, so I don't know if this is possible or not.

Read Entire Article