Skip to content
Advertisement

I am trying to know the reason my code is not running [closed]

I want to know where I have mistakes in my codes I am trying to fix it , hope someone will help )

def make_list(number) :
names = []
for item in number:

names.append(input("Enter your name') )
print (names)

number = int(input("How many names need to be entered?"))
names = make_list(number)
for name in names:
if name[1] == "A":
print("Name", name, “Starting from the work A")

Advertisement

Answer

I hope I’ve fixed all the indentations:

def make_list(number) : # function to make a list of numbers
    names = [] # create an empty list
    for i in range(number): # range(number) is a list of numbers from 0 to number-1
        names.append(input("Enter your name: ")) # append() adds an element to the end of the list
    
    return names # return the list

number = int(input("How many names need to be entered?")) # ask the user for the number of names
names = make_list(number) # call the function make_list()
for name in names: # for each name in the list
    if name[1] == "A": # if the second letter of the name is "A"
        print("Vmsa", name, "Starting from the work A") # print the name and the message
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement