jeudi 21 mars 2019

Emitting certain character from being outputted in a random password generator program

I'm writing a program that randomly generates a combination of any amount of ASCII characters.

import random
import string

string.printable
sP = string.printable

def random_pass(stringLength):
     x = sP
     return ''.join((random.choice(x)) for i in range(stringLength))
     if x == '<0x0c>' or '<0x0b>:
     print("Try again!")
print('You'\re password is: ', random_pass(12))

-What do '<0x0c>' and '<0x0b>' stand for? -During some iterations of the program, these character codes are printed out. -Do they represent white space? -My if statement in the random_pass() function doesn't omit the character codes from appearing in the output. Which is why I now seek help.




Aucun commentaire:

Enregistrer un commentaire