Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Joining results
#1
I have hit an snag at the end of this schedule maker i have been creating. The way I have been able to get my results at the end of random generators is by putting "shuffle(lifeguard) shuffle(beach) shuffle(days_off)" How can I have all of these process at the same time until "lifeguard" runs out of values and then to put it into some kinda of order.
import random

beach = ['Civic','Middle', '2 Chair', 'Main', 'Malibu', 'Nassau 2', 'Nassau 5', 'Reef', 'Anchor', 'E.lido', 'Lido', 'W.Lido', 'Surfing Bay', 'Lido West', 'EAB', 'E.EAB', 'Sea Glades']
lifeguard = ['Rodriguez','Mills', 'L Fitzgerald', 'Laibach', 'Hannon', 'Ruddick', 'Pitzer', 'TFlannigann', 'Vurro', 'Harrington', 'Chase', 'Clarkson', 'Digregorio', 'Nicharkwick', 'Riobo', 'Czartoyski', 'Meringolo', 'Brady', 'Barklow', 'Treadwell', 'Flynn', 'Geodecke', 'Murphy', 'Spinella', 'Joyce', 'TFitzgerald', 'Dreidy', 'EMquade', 'Schroeder', 'Mcveigh', 'Harloff', 'Rtreadwell', 'Cdauria', 'Ochs', 'Mriordan', 'Scibelli', 'Shanley', 'Charkowick', 'Kappel', 'Shutkind', 'Tcrafa', 'BCreigh', 'JCrafa', 'Creagh', 'Fitzpatrick', 'Curry', 'KFlannigan', 'Schlicte', 'Aicher', 'Kinneally', 'CCrafa', 'Fahy', 'Mulloolly', 'Zimmerman', 'Marcote', 'Kluss', 'Wiets', 'Duaria', 'PMquade', 'Campbell', 'Ptucker', 'Henderson', 'Lupia', 'Dunn', 'Rainus', 'lark', 'Peers', 'TLark',  'Martinez', 'Scheinburg', 'Rainus', 'Techera', 'Mcglughlin', 'Carr', 'Farrel', 'Bergin', 'Demeo', 'Trebel', 'Vanella', 'Serrao', 'Brown', 'Paoli', 'Dilsner', 'Swanson', 'JBurns', 'Stapleton', 'Correa', 'Formes', 'Hurst', 'BHarrington', 'Marks', 'MByrne', 'Boccio', 'Neuwieth', 'Babel', 'Hooker', 'Orourke', 'Martinsen', 'Leone', 'Wiessburg', 'Compton', 'Mazur', 'Tucker', 'Kerr', 'Dunster', 'Hutchinson', 'TFahy', 'Giordana', 'Hughes', 'Mahony', 'Gallego', 'CoNewby', 'Vitale', 'Shineburg', 'Longo', 'Michelman', 'Henne']
days_off = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
print ('To add an lifeguards type "lifeguard.append(name of lifeguard)"')
print ('To remove an lifeguard type "lifeguard.pop(name of lifeguard)"')
print ('To get your Schedule type "XXXXXX"')


def shuffle(lifeguard):
    #randomly picks one lifeguard out from array lifeguard
    if len(lifeguard) > 0:
        random.shuffle(lifeguard)
        win = lifeguard.pop()
        print (" %s" % win)
    else:
        print ('There are no more lifeguards')

        
def shuffle(beach):
    #randomly picks one beach out from array beach
        random.shuffle(beach)
        win = beach[1]
        print (" %s" % win)



def shuffle(days_off):
    #randomly picks one beach out from array beach
        random.shuffle(days_off)
        win = days_off[1]
        print (" %s" % win)
Reply
#2
and your question is?
Recommended Tutorials:
Reply
#3
(Sep-04-2017, 10:38 PM)metulburr Wrote: and your question is?

I by a mistake posted the thread without writing anything. Fixed that
Reply
#4
Do a while lifeguard: loop. Each time through the loop, pop a lifeguard, pick a random beach, and pick a random days off.

I don't think this will work too well as a scheduler. You could end up with no lifeguards on a given beach or a given day.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(Sep-04-2017, 10:44 PM)ichabod801 Wrote: Do a while lifeguard: loop. Each time through the loop, pop a lifeguard, pick a random beach, and pick a random days off.

I don't think this will work too well as a scheduler. You could end up with no lifeguards on a given beach or a given day.

Its set up to give a lifeguard a beach and day off until there are no more lifeguards
Reply
#6
Quote:
import random
 
beach = ['Civic', 'Middle', '2 Chair']
lifeguard = ['Rodriguez', 'Mills', 'L Fitzgerald']
days_off = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
 
def shuffle(days_off):
    #randomly picks one beach out from array beach
        random.shuffle(days_off)
        win = days_off[1]
        print (" %s" % win)

I've reposted your exact code, doing nothing but removing some things that don't matter.

If you define a function, and then define a function with the same name, then the original function no longer exists. So don't do that if you want to use all three of those functions. The proof is in the spam-colored pudding:
>>> def echo(a):
...   print("A: {}".format(a))
...
>>> def echo(b):
...   print("B: {}".format(b))
...
>>> def echo(c):
...   print("C: {}".format(c))
...
>>> a = "spam"
>>> echo(a)
C: spam
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Joining two jupyter notebooks and getting an error! Led_Zeppelin 1 1,147 Oct-20-2022, 04:28 PM
Last Post: deanhystad
  What is the value after JOINING an empty list? JaneTan 2 5,236 Jan-04-2021, 06:25 PM
Last Post: deanhystad
  Search Results Web results Printing the number of days in a given month and year afefDXCTN 1 2,245 Aug-21-2020, 12:20 PM
Last Post: DeaD_EyE
  How to append one function1 results to function2 results SriRajesh 5 3,178 Jan-02-2020, 12:11 PM
Last Post: Killertjuh
  Python - joining xmls together invalid token error jan86 0 2,220 Apr-26-2019, 08:52 AM
Last Post: jan86
  Joining two tables together tryingtolearnpython 0 2,231 Jul-22-2018, 11:29 AM
Last Post: tryingtolearnpython
  Joining a Daemon Thread QueenSvetlana 3 3,596 Nov-21-2017, 11:39 PM
Last Post: Windspar
  joining a variable number of lists in a comprehension Skaperen 2 2,823 Oct-14-2017, 08:19 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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