+ 1

Random letter

In python, how would i pick a random letter from the alphabet using the function guess_letter()? -I tried using a list but I must have did it wrong because it does not work

3rd Feb 2018, 5:15 PM
Nick DiPaolo
Nick DiPaolo - avatar
5 Answers
+ 2
import random def guess_letter(); a = random.choice(ascii_letters) print a —I don’t think this is correct but this is how i approached it
3rd Feb 2018, 5:51 PM
Nick DiPaolo
Nick DiPaolo - avatar
+ 1
you must observe that: - ascii_letters is defined in string module - You must print a but a is in function scope and you search it in a "more" extern scope (eg. a is not visible in print call)
3rd Feb 2018, 6:11 PM
KrOW
KrOW - avatar
+ 1
ok thank you very much
3rd Feb 2018, 6:15 PM
Nick DiPaolo
Nick DiPaolo - avatar
+ 1
👍👍👍👍
3rd Feb 2018, 6:16 PM
KrOW
KrOW - avatar
0
Post your code please and when we work on that
3rd Feb 2018, 5:43 PM
KrOW
KrOW - avatar