0

I want to use some function in python

That function must return me any random string from a given array or list ..... How and which function could be used to solve this problem !!!!

1st May 2020, 7:43 AM
Dhrumil Sheth
Dhrumil Sheth - avatar
6 Answers
+ 3
use randint from random module
1st May 2020, 7:52 AM
Abhay
Abhay - avatar
+ 3
# you can use random module import random chars = 'abcdefghijklmnopqrstuvwxyz' use: random.choice(chars). If you need to get more than one character, you have to run this expression in a loop or in a comprehension. or use: random.choices(chars, k = n), where n is the number of desired characters. This does not need to run in a loop.
1st May 2020, 10:39 AM
Lothar
Lothar - avatar
1st May 2020, 8:25 AM
Abhay
Abhay - avatar
0
Thanks šŸ˜ƒšŸ˜ƒšŸ˜ƒšŸ˜ƒ
1st May 2020, 9:15 AM
Dhrumil Sheth
Dhrumil Sheth - avatar