python
Random numbers List with no repetition - generate in python
The code will generate a random list with no repetitive numbers. This will contain 15 items and they will be selected from a range of 0 to 70.
import random
final_list = random.sample(range(70), 15)
print(final_list)
Output
[46, 14, 35, 17, 2, 13, 61, 15, 63, 30, 0, 43, 44, 39, 58]
-- Output will be different each time the code will run.
-- Output will be different each time the code will run.
Was this helpful?
Similar Posts
- How to generate a random number in python using random module
- Generate a list of n numbers in Python
- Python program to Generate a Random String
- Get a random item from a List in Python
- [Python] Range - standard function to create a list of numbers
- Python - regex,replace all character exept A-Z a-z and numbers
- Python - String ,remove,delete,replace,extract numbers from string