Home > other >  A group of random group python?
A group of random group python?

Time:04-02

Import the random
Class=[' zhang ', 'bill', 'Cathy', 'almanac']
Class2=[' zhao 6 ', 'the king', 'li ho', 'Zhao Li]

Class with class2 how random group, a class a, don't repeat? For example [zhang SAN, li ho], [li si, Zhao Li]...

CodePudding user response:

Don't repeat, the candidates to remove after
 

Import the random
Class1=[' zhang ', 'bill', 'Cathy', 'almanac']
Class2=[' zhao 6 ', 'the king', 'li ho', 'Zhao Li]

While len (class1) & gt; 0:
Int1=random. Randint (0, len (class1) - 1)
Int2=random. Randint (0, len (class2) - 1)
Print (class1 [int1], class2 [int2])
Class1. Remove (class1 [int1])
Class2. Remove (class2 [int2])

  • Related