Siva-770 / problems

This is my demo
0 stars 0 forks source link

Python #1

Open Siva-770 opened 1 month ago

Siva-770 commented 1 month ago

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

Siva-770 commented 1 month ago

def capitalize_names():

Input: A comma-separated list of names as a string

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)

Call the function to run

capitalize_names()

hassaankreative commented 1 month ago

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())

Prateeeek7 commented 1 month ago

x=input("Enter the names:") names=x.split(",") for i in range(0,len(names)): c=names[i].capitalize() print(c)

Hacksmith01 commented 1 month ago

names = input("Enter names seperated by a comma: ")

names_list = names.split(',')

for name in names_list: capitalized_name = name.capitalize() print(capitalized_name)

asmarabbasli commented 1 month ago

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)

vulnerablevarun commented 1 month ago

here the comma separated names means list of name -datatype-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())

Lokesh1933 commented 1 month ago

prints First letter capitalized and on next line enter the comma separated list of names

name_str = input("Enter the list of names: ") names = name_str.split(',') for name in names: format_name = name.strip().capitalize() print(format_name)