Ask coding questions

← Back to all posts
How to make userinput print only the asked amount characters in password.
BrockTempler1

In the function main3() I want to randomly combine letters and numbers when 3 is pressed. ALso the user can choose how many characters they want in their password right now when they choose 6 characters it will print 12 and I want it to be 6. I tried dividing userinput by 2 but you can obviously tell that would create some problems and doesn't work in the first place. Also I haven't figured out how to randomize the letters with the numbers yet? Please help me!
(scroll down to line 48 for the function that needs help.

Voters
BrockTempler1
Comments
hotnewtop
HayIsForHorses
BrockTempler1

I know its hard to understand what I'm trying to convey. When the user clicks 3 he is directed to input characters for a mix of letters and numbers for his password. If he types 4 then I want it to have a randomized output of letters and numbers. That is what I'm trying to [email protected]

HayIsForHorses

@BrockTempler1 well 3 is easy, but 4, you have to set a character number, or have the user type in how many characters they want. I'll show you how to do it without character input:
edit: i saw u wanted user num input so i added it

Hope I helped!

BrockTempler1

The password variable is 'invalid syntax', [email protected]

HayIsForHorses

@BrockTempler1 where does it say invalid

HayIsForHorses

@BrockTempler1 if you copypasted my code try fixing the indents and removing comments

MrVoo

Not sure what you're asking, but wouldn't this work?

BrockTempler1

In main3() I ask the user how many characters they want but the amount of characters doubles as you can see when pressing 3 then typing in for example [email protected]

MrVoo

@BrockTempler1 You added a letter AND a number for each iteration, make it random.

BrockTempler1

The numbers and letters are randomized by them self I just can't combine them and make it randomized also when the user types he wants 6 characters he gets 12 the way I have it set up which I don't want it that way. @MrVoo

MrVoo

@BrockTempler1 Pick a random item from a combination of string.digits and string.ascii_letters

BrockTempler1

I'm disabled in the world of python. @MrVoo

MrVoo

@BrockTempler1 Make a variable worth both of them ._.

BrockTempler1

They are variables. I don't think im following. @MrVoo

MrVoo

@BrockTempler1 -.-