I need to find the position of a number which is randomly chosen within certain ranges. EX: (start, stop, step): (3,6,1) This corresponds to (3,4,5,6) Out of this one number is chosen randomly and I want to find a way to get the position of the number after enumerating it without using lists.
The code looks like the following:
tuple_val = (3,6,1) #or any value
rand_val = randint(tuple_val[0], tuple_val[1])
for val in range(tuple_val[0], tuple_val[1], tuple_val[2]):
if rand_val == val:
#FIND INDEX OF rand_val
how would I go about finding the index of this random number?
Aucun commentaire:
Enregistrer un commentaire