Write a python program to take full name of 2 users separately(name 1 and name 2), and print the number of letters in name 1, then printname 2 number of times equal to the number of letters in name 1.
Question
Write a python program to take full name of 2 users separately(name 1 and name 2), and print the number of letters in name 1, then printname 2 number of times equal to the number of letters in name 1.
Solution
Sure, here is a simple Python program that accomplishes what you're asking for:
# Step 1: Take full name of 2 users separately
name1 = input("Enter the full name of user 1: ")
name2 = input("Enter the full name of user 2: ")
# Step 2: Calculate the number of letters in name 1
num_letters = len(name1.replace(" ", "")) # We replace spaces because they are not letters
# Step 3: Print the number of letters in name 1
print("Number of letters in name 1: ", num_letters)
# Step 4: Print name 2 number of times equal to the number of letters in name 1
for i in range(num_letters):
print(name2)
This program first takes the full names of two users. It then calculates the number of letters in the first user's name (excluding spaces), and prints this number. Finally, it prints the second user's name a number of times equal to the number of letters in the first user's name.
Similar Questions
Complete the program below. It should:define a function thatasks the user for their first nameasks the user for their last namereturns "x y", where x is their first name and y is their last nameoutputs the result of the function
Write a Python program that inputs a user's first and last name and prints them in reverse order with a space in between.For example, if the program inputs the first name "Joe" and the last name "Bakers," it should output:Bakers Joe
ou are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following:Hello firstname lastname! You just delved into python.
Given the following:name=["Kim","Bob","Jose","Selena","Chou"]ages=[19,22,21,24,31]Write a program using a for loop that prints: Kim 19Bob 22Jose 21Selena 24
Write a Python program to get a dictionary value from the user and count the number of keys that are having the same value and print the count.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.