1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2012
Posts
2
Rep Power
0

#### Help!??

I am fairly new to python, so i thought i would mess around and make a command program. What it does is send out 200 numbers randomly generated of 1's and 2's and then counts them and displays the outcome and the total number count. I was wondering if someone could help me because i want the outcome and the print line on one line. here is my script:
Code:
```total=0
sone=0
stwo=0

while total<200:
import random
num = random.randint(1,2)
print num
total=total+1
if num==2:
stwo=stwo+1
if num==1:
sone=sone+1
if total==200:
print "This program is about to start counting the 1's and 2's"
print "this program will now count the total of 1's and 2's"
print ""
print ""
print "*****************************************************************************"
print "twos were found in this run,the total count of ones are:"
print sone
print "---"
print"the total 2's that show up are:"
print stwo
print "---"
print "the total number of 1's and 2's used is :"
print total```
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2012
Posts
2
Rep Power
0
I made an edit to my file and now it doesnt work, the raw data seams to not send the data right or something:
Code:
```total=0
sone=0
stwo=0

var=raw_input("Enter a number: ")
while total<var:
import random
num = random.randint(1,2)
print num
total=total+1
if num==2:
stwo=stwo+1
if num==1:
sone=sone+1
if total==var:
print "This program is about to start counting the 1's and 2's"
print "this program will now count the total of 1's and 2's"
print ""
print ""
print "*****************************************************************************"
print "twos were found in this run,the total count of ones are:"
print sone
print "---"
print"the total 2's that show up are:"
print stwo
print "---"
print "the total number of 1's and 2's used is :"
print total```
3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jul 2012
Posts
39
Rep Power
3
I think the answer you are looking for is use a comma to separate the text and and the value on the print line. For example

Code:
```print "Total count of ones are:", sone
print "---"
print "Total 2's that show up are:", stwo
print "---"
print "Total number of 1's and 2's used is :", total```
PS You don't need the import line in the loop; move it to the top. You are actually calling import random 200 times; Python will know it has already imported it before and skip the last 199 requests.