Post: Python Help For School
10-14-2011, 12:09 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); I have this school project where I need to make groups randomly with python...we have most of it set up and running fine but I wanted to know if someone could help me get it so that it will not print the same name twice as in vinny vinny or joe joe

Heres the python Code:


import random
mylist = ['anthony', 'kris', 'james', 'vinny', 'joe']
randomList1 = random.randrange(0,len(mylist))
randomList2 = random.randrange(0,len(mylist))
name2 = mylist[randomList1]
name3 = mylist[randomList2]
print 'The group will consist of', name2, 'and', name3,'. '


help will be REALLY appreciated
(adsbygoogle = window.adsbygoogle || []).push({});
10-14-2011, 01:17 AM #2
Cory
User needs a dick
Originally posted by vinnic12 View Post
I have this school project where I need to make groups randomly with python...we have most of it set up and running fine but I wanted to know if someone could help me get it so that it will not print the same name twice as in vinny vinny or joe joe

Heres the python Code:


import random
mylist = ['anthony', 'kris', 'james', 'vinny', 'joe']
randomList1 = random.randrange(0,len(mylist))
randomList2 = random.randrange(0,len(mylist))
name2 = mylist[randomList1]
name3 = mylist[randomList2]
print 'The group will consist of', name2, 'and', name3,'. '


help will be REALLY appreciated


Is it showing like this? 'The group will consist of', Kriss Kris, 'and', Vinny Vinny,'. ' Showing both names still? Or is it just posting the same name in BOTH spaces?
10-14-2011, 02:26 AM #3
I just it prints randomly like it will say joe and anthony or any two names randomly but I wanna prevent it from posting the same name twice because once in a while it will post vinny and vinny
10-14-2011, 10:24 AM #4
Originally posted by Poynt View Post
Is it showing like this? 'The group will consist of', Kriss Kris, 'and', Vinny Vinny,'. ' Showing both names still? Or is it just posting the same name in BOTH spaces?


Like once and awhile it will print the same name in both spaces...and I need to know how to fix that
10-18-2011, 04:21 AM #5
glitchplz
Samurai Poster
Originally posted by vinnic12 View Post
Like once and awhile it will print the same name in both spaces...and I need to know how to fix that


Check your thread in the coding questions, I posted a solution

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo