Using python generate random names and address to csv format

Question:

Using python how do i generate randon names in the format of random email, first name , last name, address, city, state, zip, country(USA only)

Asked By: bruce_karlo

||

Answers:

To generate random names you will need to have a database of names. However, if you can pass off any combination of letters as names then you can achieve this using random.choice. Refer below code which prints out 15 names and the length of names is between 3 and 25 characters. You can extend the same logic for random emails.

import random
letters = "abcdefghijklmnopqrstuvwxyz"
random.choice(letters)

population = 15

for a in range(population):
    print(" ")
    for b in range(random.randint(3,25)):
        print(random.choice(letters), end='')
Answered By: Mayank R
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.