Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading