why join function is not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

3rd Sep 2020, 3:23 PM
Somil Khandelwal
2 Answers
+ 2
Because random.choices returns an array, you have to join that returned value: print(" ".join(random.choices(new_encryption_key, k=10)))
3rd Sep 2020, 3:28 PM
Bagon
Bagon - avatar
+ 1
Yeah it basically joins with spaces. Also you can just give it a list (no need for new_encryption_key)
3rd Sep 2020, 3:33 PM
Bagon
Bagon - avatar