## Norbert X 42

I've been racking my brain on this problem for like 2 hours. The thing I have to do here is use one single random function for the entire MASH program instead of the usual 4. The problem is, when I get a result, they're all from catagory 1 (married to girl1, driving a car1 living in house1, etc.) How can I get different results? Here's what I have so far:

``````import random

house = ["a mansion", "an apartment", "a shack", "a house"]
spouse = ["name1", "name2", "name3", "name4"]
car = ["car1", "car2", "car3", "car4"]
kids = ["no kids", "1 kid", "2 kids", "5 kids"]

print"List 3 people you want to marry in the future:"
spouse[0] = raw_input("1. ")
spouse[1] = raw_input("2. ")
spouse[2] = raw_input("3. ")

print"List 1 person who you don't like: "
spouse[3] = raw_input("1. ")

print"List 3 cars you want in the future:"
car[0] = raw_input("1. ")
car[1] = raw_input("2. ")
car[2] = raw_input("3. ")

print"List 1 car that you don't like: "
car[3] = raw_input("1. ")

#main
while True:
z = random.randrange(3)
b = z
raw_input("Now mashing... Press [enter] for your results")
print "You will live in",house[b]
print "Married to",spouse[b]
print "Driving a",car[b]
print "With",kids[b],"running around the house"
choice = raw_input("Do you want a second chance? Type [n] to quit. ")
if"n"in choice:
break

raw_input("Press [Enter] to exit.")``````

The main problem is b and z. I can't figure it out. Could some one help me?

## Paul Thompson 178

Well if you want them to all be in a different category then you have to get a new number each time. Also you can use random.choice() to get a random choice from a list.

Here is what i would do

``````import random

house = ["a mansion", "an apartment", "a shack", "a house"]
spouse = ["name1", "name2", "name3", "name4"]
car = ["car1", "car2", "car3", "car4"]
kids = ["no kids", "1 kid", "2 kids", "5 kids"]

print"List 3 people you want to marry in the future:"
spouse[0] = raw_input("1. ")
spouse[1] = raw_input("2. ")
spouse[2] = raw_input("3. ")

print"List 1 person who you don't like: "
spouse[3] = raw_input("1. ")

print"List 3 cars you want in the future:"
car[0] = raw_input("1. ")
car[1] = raw_input("2. ")
car[2] = raw_input("3. ")

print"List 1 car that you don't like: "
car[3] = raw_input("1. ")

#main
while True:
raw_input("Now mashing... Press [enter] for your results")
print "You will live in",random.choice(house)
print "Married to",random.choice(spouse)
print "Driving a",random.choice(car)
print "With",random.choice(kids),"running around the house"
choice = raw_input("Do you want a second chance? Type [n] to quit. ")
if"n"in choice:
break

raw_input("Press [Enter] to exit.")``````