This is a basic Mash program assignment I have to do but I have a few problems, and I don't know how to edit it.
It is suppose to look like this: http://i43.tinypic.com/inv0gj.jpg
but mine look slightly different: (copy and paste the code to ur python to check if you need too.)

Problem:
- How do I seperate the buttom paragraph so it's not all grouped together?
- How do I put something in a whole sentence (the "#conclusion" part at above)
- How do I make the outcomes come out randomly..
I found out a problem that when it says
"You live in a (HOUSE)"
"Married to (SPOUSE)" .. etc
^ Part, I realied it isn't coming out with random and different answers. I've re-run the program and it gives out the same outcome everytime.

SUMMARY:
Basically I want this program to look like the one above(linked), and I don't know how to edit mine to become like it.. Any tips/help please?

house =["Mansion", "Apartment", "Shack", "House"]
spouse =["EMPTY", "EMPTY", "EMPTY", "EMPTY"]
car =["EMPTY", "EMPTY", "EMPTY", "EMPTY"]
kids =["0", "1", "2", "5"]

print "Enter the name of three people you could marry: "
name1 = raw_input("Name1:")
spouse[0]= name1
name2 = raw_input("Name2:")
spouse[1]= name2
name5 = raw_input("Name3:")
spouse[2]= name5

print "Enter the name of one person you wouldn't want to marry:"
name4 =raw_input("Name4: ")
spouse[3]= name4

print "Enter the name of 3 cars you want: "
car1 =raw_input("car1:")
car[0]= car1
car2 = raw_input("car2:")
car[1] = car2
car3=raw_input("car3:")
car[2]=car3
print "Enter the name of one car you don't want: "
car4 =raw_input("car4:")
car[3]=car4


#conclusion
print "You will live in a: "
for i in range(1):
    print house[i]
print "Married to: "
for i in range(1):
    print spouse[i]
print "While driving your: "
for i in range(1):
    print car[i]
print "With your "
for i in range(1):
    print kids[i]
    print "kids in it"

Recommended Answers

All 5 Replies

Here's some examples of string formatting:

>>> my_car = 'Ford'
>>> my_friend = 'Bob'
>>> print 'Hai.  I drive a %s with my friend %s' % (my_car, my_friend)
Hai.  I drive a Ford with my friend Bob
>>> print 'Wait, I too drive a', my_car, 'with my friend', my_friend
Wait, I too drive a Ford with my friend Bob
>>> msg = 'What?!  No wai we both drive %s cars and have friends named %s?!'
>>> print msg
What?!  No wai we both drive %s cars and have friends named %s?!
>>> print msg % (my_car, my_friend)
What?!  No wai we both drive Ford cars and have friends named Bob?!
>>>

Hope that provides a tiny bit of insight into improving your class assignment

Oh, and you'll need to make use of the random module to randomize your selections

I don't get it, that didn't help that much. (i'm a beginner)
Thanks for the website, I saw the buttom part (green box) , and it seems like most of the codes are for random integers and it doesn't work for 'items' or 'variables' Help? :I

Check this out, see if it gives you a bump in the right direction

import random
houses = ['mansion','chateau','average','duplex','apartment','studio']
print random.choice(houses)

Check this out, see if it gives you a bump in the right direction

import random
houses = ['mansion','chateau','average','duplex','apartment','studio']
print random.choice(houses)

Oh sweet, thanks :D Now I know how to do the random choices :)
Do you know how I can make the outputs (python shell), the words/sentances in sections so the whole program won't be all grouped together, and all you see is a group of text.

I tried spacing the codes out while typing them but when it outputs it's all grouped in a big 'blob'

You will have to add a few extra print statements to space it out:

import random

house =["Mansion", "Apartment", "Shack", "House"]
spouse =["EMPTY", "EMPTY", "EMPTY", "EMPTY"]
car =["EMPTY", "EMPTY", "EMPTY", "EMPTY"]
kids =["0", "1", "2", "5"]

print "Enter the name of three people you could marry: "
name1 = raw_input("Name1: ")
spouse[0]= name1
name2 = raw_input("Name2: ")
spouse[1]= name2
name5 = raw_input("Name3: ")
spouse[2]= name5

print
print "Enter the name of one person you wouldn't want to marry:"
name4 =raw_input("Name4: ")
spouse[3]= name4

print
print "Enter the name of 3 cars you want: "
car1 =raw_input("car1: ")
car[0]= car1
car2 = raw_input("car2: ")
car[1] = car2
car3=raw_input("car3: ")
car[2]=car3
print
print "Enter the name of one car you don't want: "
car4 =raw_input("car4: ")
car[3]=car4


#conclusion
print '-'*40  # prints 40 dashes across
print "You will live in a:", random.choice(house)
print "Married to:", random.choice(spouse)
print "While driving your:", random.choice(car) 
print "With your", random.choice(kids), "kids in it!"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.