0

How can i randomly select the character? Currently hard code "b" & "c"

Function: def getLttr(): stringList = list('abcdefghij') shuffle(stringList) return ''.join(stringList) In main: letter = getLttr() num1 = letter.find("b") num2 = letter.find("c")

31st Aug 2020, 6:26 PM
SWL
4 Respuestas
+ 4
Are you really needing 2 numbers / indexes back? Can you talk a bit more about what you want to achieve? Thanks!
31st Aug 2020, 8:25 PM
Lothar
Lothar - avatar
+ 2
from random import choice print(choice(['a', 'b'])
31st Aug 2020, 7:24 PM
Namit Jain
Namit Jain - avatar
0
Yh... The choice function's best for that..
31st Aug 2020, 7:42 PM
...
... - avatar