[Python] Generate list of random names - Python

Discussão em 'Python' iniciado por Stack, Julho 14, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to create a list of names, with each one being different. Here is my code right now, but all it does it create multiple instances of the same name.

    import random

    first_names=('John','Andy','Joe')
    last_names=('Johnson','Smith','Williams')

    full_name=random.choice(first_names)+" "+random.choice(last_names)

    group=full_name*3


    For example, this would show up as:

    John Smith
    John Smith
    John Smith


    But I want something like:

    John Williams
    Andy Johnson
    Joe Johnson

    Continue reading...

Compartilhe esta Página