Password generator script
Your sentiment is indeed correct, this code is much longer than it needs to be and can be shortened 10x while retaining the same functionality.



You are doing 4 things in a single function!


Asking for input
Generating a password
Printing
Writing to a file.


A function should do 1 thing only.

Let's say we want to generate a password:

def generate_password():
    numbers = (str(random.randint(10, 99)) for _ in range(4))
    letters = (random.choice(string.letters) for _ in range(4))
    return ''.join(numbers) + ''.join(letters)


This function is shorter than yours not only because it does not care about Input/Output, but also because it uses loops (Generator expressions here) to do the same thing many times.

You may call this function in a user-interface that handles input and output like:

print(raw_input("Username ") + " " + raw_input("Surname ") + ": " + generate_password())


Of course you may want to make the interface nicer or make it handle files, but the backbone is here.