0
why join function is not working
import random import re msg=input("Enter Your Message : ") encryption_key=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1", "2","3" ,"4", "5" ,"6", "7", "8", "9", "10"] new_encryption_key="".join(encryption_key) if len(msg)<=20: print(random.choices(new_encryption_key ,k=10)) else: print("access granted") print() print(msg) https://code.sololearn.com/ceni8XgqEEc5/?ref=app
3 ответов
+ 2
Because random.choices returns an array, you have to join that returned value:
print(" ".join(random.choices(new_encryption_key, k=10)))
+ 1
Yeah it basically joins with spaces. Also you can just give it a list (no need for new_encryption_key)