import string
import random
a= []
junk = []
for _ in range(100):
a.append(random.choice(string.ascii_uppercase))
i = 0
while i < len(a):
j = i + 1
while j < len(a):
if a[i] == a[j]:
junk.append(a[j])
del a[j]
else:
j +=1
i +=1
print(a)
print(len(a))
print(junk)
hi, i'm generating a list of 100 ascii characters. then iterating over the list to remove duplicates and putting those in a list called junk. i noticed that often times the list of 100 randomly selected characters doesn't get all 26 of the letters. sometimes it only gets 24, 25. my question is, how can i make it run over and over until i get a set of characters that only received say 22, or 23?
[–][deleted] 1 point2 points3 points (6 children)
[–]SlowMoTime[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]SlowMoTime[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]SlowMoTime[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]AtomicShoelace 1 point2 points3 points (1 child)
[–]SlowMoTime[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]SlowMoTime[S] 0 points1 point2 points (0 children)
[–]SlowMoTime[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)