Please read documentation,
randomhas a usage warning at the top of the documentation:Warning: The pseudo-random generators of this module should not be used for security purposes. Use
os.urandom()orSystemRandomif you require a cryptographically secure pseudo-random number generator.Use string formatting, this simplifys the creation of strings.
Have a standard for your indentation. I'm honestly surprised this code runs with your tabbing.
You can simplify your equality checks, rather than doing
a == b or a == c, you can usea in {b, c}. I use a set due to the peephole optimization.Use loops, if you use
for _ in range(amount)you can reduce your code significantly.Move duplicate code into one function, in this case move your prints of the password out of;
small,med, andbig. And put it ingenerate.Make a single function to be able to make any sized input.
Change
generateto account for this.Use a
main. You want to keep things out of global scope, so it's as small as possible. This can lead to performance improvementsThis can lead to performance improvements.Protect your main function with a
if __name__ == '__main__':guardif __name__ == '__main__':guard.You can simplify the for loop to a list comprehension, this documentation may be easier to understandthis documentation may be easier to understand.
You can define your letters as a global constant, so that if you do need them again later, you can use the one we've defined. And so if at a later date you want to add or remove letters, then you can without having to change multiple strings.