Random letters(python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Random letters(python)

How do i generate 5 random different letters? I created this code atm https://code.sololearn.com/cau73YH6133s/?ref=app

21st Apr 2018, 6:30 PM
Guido Parlatore
Guido Parlatore - avatar
3 Answers
+ 2
TurtleShell that can duplicate letters. import random import string letters = [] letters = [l for _ in range(5) for l in random.choice(string.ascii_letters) if l not in letters] [print(l, end=' ') for l in letters]
21st Apr 2018, 6:42 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Oh sorry didn’t see the word different
21st Apr 2018, 6:43 PM
TurtleShell
TurtleShell - avatar
0
from random import choice from string import ascii_letters i=5 while i!=0: print(choice(ascii_letters)) i-=1
21st Apr 2018, 7:01 PM
Mohammad Nazmul Hossain
Mohammad Nazmul Hossain - avatar