How do you generate random characters in python?not just letters and integers..but also punctuations. (@#&_$-,.': etc.) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do you generate random characters in python?not just letters and integers..but also punctuations. (@#&_$-,.': etc.)

I wanted to generate a series of random characters to a specified range... however i could only generate random integers (random.randint) and random letters.. but how about punctuations? any help would greatly be appreciated 👍🏼

6th Mar 2017, 7:01 PM
Samuel Putra
Samuel Putra - avatar
1 Answer
+ 2
you can create a list of those symbols and use the random.choice function from the random module to generate a random symbol. 😊
6th Mar 2017, 7:21 PM
Vesse
Vesse - avatar