+ 3
How can I randomize some index value in list?
Hello, I'm trying to do a little chatbot, and I wabt to randomize some values in a list (not the entire list), I tried some random lib commands but all gave an error. So, someone have a tip for a random lib code to randomize some values in a list?
3 Antworten
+ 4
import random
list = ['a','b','c','d','f']
rndIndex = random.randint(0,len(list)-1)
print(list[rndIndex])
+ 4
cat do Chrome ,
there is not everything clear to me.
▪︎what values do you need? numbers, characters, punctuation, ... ?
▪︎have the values to be in a defined range?
▪︎do these values have to be unique ?
▪︎ how many values are required ?
▪︎ are there some values in a list that can be used by rearranging them?
if would be great when you could give us samples of the lists. maybe also give a bit more details.
thanks!
+ 2
Guys, I decided to use just two lists for it, because I didn't can to find other way. But, thanks for everyone