Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Quizzma Latest Articles

5.2.9 How Many Names CodeHS Answers

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.

Was this helpful?




Quizzma Team

Quizzma Team

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.

Related Posts

Leave a comment