Open Siva-770 opened 1 month ago
def capitalize_names():
names_str = input("Enter a comma-separated list of names: ")
# Split the input string by commas into a list of names
names = names_str.split(',')
# Iterate over each name, strip leading/trailing spaces, and capitalize the first letter
for name in names:
# Strip spaces and capitalize
capitalized_name = name.strip().capitalize()
# Print each name on a new line
print(capitalized_name)
capitalize_names()
user_input = input("Enter the Names: ") new_line = user_input.replace(","," ") words = new_line.split() for i in range(len(words)): print(words[i].capitalize())
x=input("Enter the names:") names=x.split(",") for i in range(0,len(names)): c=names[i].capitalize() print(c)
names = input("Enter names seperated by a comma: ")
names_list = names.split(',')
for name in names_list: capitalized_name = name.capitalize() print(capitalized_name)
list =input("Enter the list: ") names=list.split(",") for i in range(0,len(names)): new_list =names[i].capitalize() print("changed list-->", new_list)
names=[,"abby","jessa"] #it's is a sample of names for i in names: #as we are iterating through for loop ..the print statement prints the names seperately print(i.strip().capitalize())
name_str = input("Enter the list of names: ") names = name_str.split(',') for name in names: format_name = name.strip().capitalize() print(format_name)
Write a function to get a comma-separated list of names as input from the user, capitalize the first letter of each name, and print each name in the list on a new line. Input: A string names_str containing comma-separated names provided by the user. Each name may contain alphabets, spaces, and special characters. Output: Print each name with the first letter capitalized on a new line. Sample Input: john, doe, alice, bob Sample Output: John\ Doe\ Alice\ Bob