Python Forum
Using random.choice v.v
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using random.choice v.v
#2
I did not read the Homework rules until just now, sorry.
################current code###############
old_people = ['George', 'Bob', 'Owen']
young_people = ['Sarah', 'Gwen', 'Brittney']
mid_age = ['Larry', 'Missy', 'Greg']


import random
print(random.choice(old_people))
 
################
this is my current code and it works great. but it only produces one word like
"george"

I want it to produce in sentence form. for example

outcome: "George Sarah Missy"
or
outcome: "Bob Sarah Larry"
Etc
They are random from each list and each list is in order.

Ive tried ->
print(random.choice(old_people, mid_age)) 

just to try two together, but it wont work..

how would I pick 1 name from all three lists in sequence on the same line?
Reply


Messages In This Thread
Using random.choice v.v - by Dawkinz - Aug-31-2019, 02:34 AM
RE: Using random.choice v.v - by Dawkinz - Aug-31-2019, 03:52 AM
RE: Using random.choice v.v - by perfringo - Aug-31-2019, 03:58 AM
RE: Using random.choice v.v - by Dawkinz - Aug-31-2019, 04:30 AM
RE: Using random.choice v.v - by perfringo - Aug-31-2019, 04:33 AM
RE: Using random.choice v.v - by ThomasL - Aug-31-2019, 10:55 AM
RE: Using random.choice v.v - by Dawkinz - Aug-31-2019, 04:42 PM
RE: Using random.choice v.v - by scidam - Aug-31-2019, 03:59 AM
RE: Using random.choice v.v - by Dawkinz - Aug-31-2019, 04:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Just some second choice answers help please ajaY 6 6,618 Apr-07-2017, 08:25 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020