I only have emoticons and not text

Question:

I want to make a generator of random letters, but instead of letters I only have emoticons. Here is the code.

import random
from random import randint

#random number of characters
sym=random.randint(100,500)
num=0
bn=[]

while num < sym :
    rb=random.randint(0,1)
    bn.append(rb)
    num+=1 
print(bn) #for check

bn=str(''.join(map(str, bn)))



def decode(lst):
    txt= ''.join(map(lambda x: chr(int(x,2)), lst))
    print("txt=",txt)


decode(bn)

The code should be letters or even numbers, but don’t smile! I tried all the ways I could think of, but the result is the same

Asked By: ura uracovich

||

Answers:

Here how to use random.choice to pick a random string.

import random

sym=random.randint(100,500)
alphabet = "abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"

bn=[]
for _ in range(sym):
    bn.append(random.choice(alphabet))
bn = ''.join(bn)
print(bn)
Answered By: Tim Roberts
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.