0
1

More than 5 years have passed since last update.

[Python]0~n-1までのランダムな数字を持つリストを作る方法

Posted at

0~n-1までのランダムな順番の数字を持つリスト

例えば、nが6の時は
[3, 5, 0, 1, 4, 2]
というリストが得られる。

コードは以下の通り。

example.py
list = random.sample(range(n), k=n)

引用元

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1