samedi 10 octobre 2020

How could I get an array of n random integers that are both positive and negative integers?

For example, if I put in 4 it would produce [1, -2, -4,3]

import stdio
    
import sys
    
import random
    
    
x = int(input(sys.argv[0]))
    
    
    
randomlist = []
    
for i in range(0, x): 
 arr = random.randint(1, -x)
     
 randomlist.append(arr)

print(randomlist)
    



Aucun commentaire:

Enregistrer un commentaire