A random name generator.

★☆☆

A random name generator can be useful for creating dummy data for test purposes.

School club

Make

Write a program to output a random name from one list of forenames and another list of surnames.

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called generate_name that:

  1. Assigns an array of forenames. You can use the names: Muhammad, Noah, Jack, Lily, Sophia, Olivia or some of your own.
  2. Assigns an array of surnames. You can use the names: Wang, Smith, Devi, Jones, Kim and Rodríguez or some of your own.
  3. It returns a random forename with a space and a random surname.

Complete the main program so that:

  1. It outputs a random name.

Typical inputs and outputs from the program would be:

Lily Rodríguez
Sophia Devi
🆘 If you're really stuck, use this Parsons code sorting exercise
Complete program
# Random name generator program

# -------------------------
# Import libraries
# -------------------------
---
import random
---


# -------------------------
# Subprograms
# -------------------------
# Function to return a random name
---
def generate_name():
---
    forename_list = ["Muhammad", "Noah", "Jack", "Lily", "Sophia", "Olivia"]
    surname_list = ["Wang", "Smith", "Devi", "Jones", "Kim", "Rodríguez"]
---
    random.seed()
    forename = forename_list[random.randint(0, 5)]
    surname = surname_list[random.randint(0, 5)]
---
    return forename + " " + surname
---


# -------------------------
# Main program
# -------------------------
---
print("Press Enter to generate a new name, or input 'end' to quit.")
wait = ""
---
while wait != "end":
---
    wait = input()
---
    if wait != "end":
---
        print(generate_name())