I am just trying to make a random monster generator for an RPG I am writing. I am using Python 2.7. It's difficult to explain but I will try.
So I am trying to make it so that if "random.choice(numbers)" comes up with the "has 1" variable, it uses "random.choice(attachmentssingle)" instead of the normal "random.choice(attachments)"
This is because I don't want it to print out "has 1 legs" or "has 1 heads". Instead it would print out "has 1 leg" or "has 1 head".
Is there any way to do this without getting too complicated? (I'm very new to Python and am trying to learn it while I'm sick.)
import random
attitude = ("An excited", "An angry", "A rabid", "A sadistic", "A depressed")
nouns = ("dog", "cat", "rabbit", "snake", "bird")
compose = ("composed of")
material = ("flame.", "wood.", "ash.", "glass.", "flesh.", "metal.")
it = ("It")
attribute = ("has large mandibles,", "has a gaunt appearance,", "has no eyes or mouth,", "is invisible,", "breathes fire,", "screams endlessly,")
word = ("and it")
numbers = ("has 1", "has 2", "has 3", "has 4", "has 5", "has 6", "has 7", "has 8", "has 9", "has 10")
attachments = ("arms", "legs", "tentacles", "heads", "mouths")
attachmentssingle = ("arm", "leg", "tentacle", "head", "mouth")
moreword = ("and it")
features = ("has an unquenchable thirst for blood.", "wants to destroy all living creatures.", "is incredible lusty.", "wants to control the human race.", "has an interest in sentient life.", "hates silence.")
print random.choice(attitude), random.choice(nouns), compose, random.choice(material), it, random.choice(attribute), word, random.choice(numbers), random.choice(attachments), moreword, random.choice(features)
if random.choice(numbers) == "has 1":
print random.choice(attachmentssingle)
input('Press ENTER to exit')
EDIT: My code expected an indented block with "print random.choice(attachmentssingle)" near the bottom. But otherwise the code works just fine, it's just that I'm trying to replace "random.choice(attachments)" with "random.choice(attachmentssingle)" if "random.choice(numbers)" comes up with "has 1"
EDIT 2: I tried @user202729's suggestion and this is what I came up with:
print random.choice(attachments) if random.choice(numbers) = "has 1" else print random.choice(attachmentssingle)
However it doesn't seem to be working as it's the wrong syntax, and I've tried several different ways of typing it out but it doesn't seem to be working.
EDIT 3: @Patrick Artner hit the nail on the head, thanks a lot man! I really appreciate all you guys helping me out with this!