Certainly! Below is an example of a Python program that accomplishes what you've described. The program prompts the user for the number of names they have, collects each name using a loop, and finally prints out the full name.
# Ask the user how many names they have
num_names = int(input("How many names do you have? "))
# Initialize an empty list to hold the names
names = []
# Use a for loop to collect each name
for i in range(num_names):
name = input(f"Please enter name {i + 1}: ")
names.append(name)
# Join the names into a single string to form the full name
full_name = ' '.join(names)
# Print the full name
print("Your full name is:", full_name)
How to Use the Program:
- Run the program.
- Enter the total number of names you want to input.
- Enter each name in the order you've specified.
- The program will output your full name concatenated from the names provided.
Example Interaction:
How many names do you have? 4
Please enter name 1: John
Please enter name 2: Michael
Please enter name 3: David
Please enter name 4: Doe
Your full name is: John Michael David Doe
This simple program captures any number of name components and formats them correctly.