0
Pythons Random Modules
Can we use randint to randomize the series of values taken from a user for eg. print(""Enter five numbers) a=list(range(5)) for i in range(5): a[i]=int(input()) random.randint(a) print(a)
14 Antworten
+ 1
If you just want to randomize the order of the array, random.shuffle(a) will do the job.
+ 3
randint(1,10)-5 would yield -4 to 5 to be added to entered number
+ 2
We can, but your example won't work.
+ 2
Definitely not like you coded it. Let's say I enter
10 30 40 20 0
as my five numbers. What kind of values would you like to see? +/-10. I assume you want your numbers to be somewhat related to the entered numbers.
+ 2
By what amount
+ 2
from random import shuffle as s
a=list(range(5))
for i in range(len(a)):
a[i]=int(input())
s(a)
print(a)
+ 1
Do it yourself, you'll learn more from it. You're on the right track.
+ 1
ok tnx anyways now i atleast know its possible
+ 1
i didn't get it @john wells
+ 1
I think you want to print one of the 5 inputs? Remember that you access the single inputs in your array with a[i], so you have to randomize your i.
+ 1
yus @chris
+ 1
thnx @chris thats what i wanted
0
thnx bt can u show me a proper example
0
yes jus randomized