Python Forum

Full Version: help returning a list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey guys, I'm trying to write a small script to return a list of numbers that are input however for the life of me I cannot get it to work, below is the script that I have and that is also straight out of my text book, whenever I am putting numbers in it is just giving me the same thing that I entered I need it to tell me how many numbers are in the list, I know that this seems really basic but I'm just learning can anyone help and keep it as simple as possible or as close to the example below that is from my book - if any help im using IDLE 3.7.0 thanks and appologies to the mods if I have not put the code in properly below

def list_length(a_list):
    """"Return the length of a list."""
    length = 0
    for item in a_list:
        length = length + 1
    return length
to get length of a list, it's simply len(listname) , to return a list from a function, return listname