Python randomly ordered for debriefing, sweepstakes and other sectors

Python implementation randomly ordered

Use shuffle () function to achieve a random sort the list

from random import shuffle
name = ["a", "b", "c","d", "e"]
shuffle(name)
for i in name:
    print(i)
for i, j in enumerate(name):
    name[i] = (i + 1).__str__() + ':' + j.__str__()
print("---随机顺序---")
for i in name:
    print(i)

Run results shown in Figure:
operation result

Published 33 original articles · won praise 1 · views 4170

Guess you like

Origin blog.csdn.net/qq_39827677/article/details/103453037