The most common answer is:
NumOfNames = int(input(“How many names you have “))
Name = “”
for i in range(NumOfNames):
NumOfNames = input(“enter each of your name “)
Name += str(NumOfNames)+” “
print(Name)
For this program to run correctly and adhere to Python syntax, including using standard ASCII quotation marks and improving variable naming for clarity, here’s the revised version of the code:
num_of_names = int(input("How many names do you have? "))
name = ""
for i in range(num_of_names):
individual_name = input("Enter each of your names: ")
name += individual_name + " "
print(name)
This program will:
- Prompt the user to enter the total number of names they have.
- Use a
for
loop to ask the user to input each name, appending each entered name to a string with a space after each name for separation. - Print the concatenated string of names after all names have been entered.