My code is trying to generate a list of random integers in the form of a list in a range. I don't really know the format of random generating or putting multiple characters in a list and couldn't for the things I wanted online. This is what I tried so far below:
Example: Number of values: 5 Low value: -100 High value: 100
Values: [70, 60, 85, 90,-10]
Function:
i = 1
while i < n:
generated = randrange(low, high,n)
values = list[generated]
i += 1
return values
Main:
from functions import generate_integer_list
# Inputs
n = int(input("How many number of values to generate(>0): "))
low = int(input("What's the lowest value in the range: "))
high = int(input("What's the highest value in the range: "))
# Outputs
values = generate_integer_list(n, low, high)
print(values)
Aucun commentaire:
Enregistrer un commentaire