1

This function takes, as an argument, a positive integer n and generates 3 random numbers between 200 and 625, the smallest random number will be called minValue, the middle random number will be called myTaret, and the largest random number will be called maxValue.

def usingFunctionsGreater(n):
#create random numbers
aList=[]
for i in range(3):
    aList.append(random.randrange(200,625,1))
    #assign minValue, myTarget, and maxValue

the comments should help explain the program that i want to write, but I have no clue how to assign the variables to the elements in the list that is generated.

2
  • 1
    What is the role of n here?
    – user2285236
    Commented Sep 9, 2016 at 20:20
  • 1
    Can't you just sort aList by ascending order?
    – jacob
    Commented Sep 9, 2016 at 20:21

1 Answer 1

4

How about the following:

>>> min, target, max = sorted([random.randrange(100, 625, 1) for i in range(3)])
>>> min, target, max
(155, 181, 239)
>>> 
2
  • 1
    Thank you so much for the help.
    – J. Wade
    Commented Sep 9, 2016 at 20:28
  • 1
    @J.Wade If this solves your problem, rather than (or in addition to) saying "thank you" you could mark this answer as the solution. You get rep, he gets rep, everybody's a winner.
    – pjs
    Commented Sep 9, 2016 at 21:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.