Hey guys I dont want the console to print duplicated letters can anyone solve this?
import random
random_list = ["a","b","c","d","e","f"]
for i in range(5):
test = random.choices(random_list)
print(test)
Hey guys I dont want the console to print duplicated letters can anyone solve this?
import random
random_list = ["a","b","c","d","e","f"]
for i in range(5):
test = random.choices(random_list)
print(test)
remove the item after you print it with .pop()
import random
random_list = ["a","b","c","d","e","f"]
for i in range(5):
test = random.choices(random_list)[0]
random_list.pop(random_list.index(test))
print(test)
You have different options.
simply remove the item from the existing list.
create a used list and check that items are not in that list.
here is an example of method 2:
import random
random_list = ["a","b","c","d","e","f"]
used_list = []
for i in range(5):
test = random.choices(random_list)
if test not in used_list:
print(test)
used_list.append(test)