TypeError 'NoneType'

advertisements

Could someone explain why my list is still a typeError 'NoneType'? I have been stuck on this for the past hour.

Even if I write f([1,2,3]) it tells me it is of NoneType.

Thank you.

   <type 'list'>
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-64-6f4003fa2858> in <module>()
        415 TotalTime = 0
        416 RandExtNumbList = []
    --> 417 fc, PeriodNumbers,TotalTime,RandExtNumbList = f(Chosen_Columns_best_result[:])
        418
        419 ########################################################################

    TypeError: 'NoneType' object is not iterable

def f(var):
    for i in range(0,len(var)):
        # Whole lot of code

    return TotalValue, Period_Numbers_per_Column, Time, ListRandExt

Chosen_Columns_best_result = ([254, 255, 243, 242, 225, 226, 203, 202, 201, 224, 241, 253, 262, 261, 252, 240, 239, 238, 237, 236, 246, 247, 248, 249, 250, 258, 257, 256, 235, 234, 233, 232, 215, 216, 217, 218, 219, 220, 197, 169, 143, 168, 196, 195, 167, 142, 166, 194, 193, 192, 164, 165, 191, 214, 190, 189, 188, 198, 199, 200, 174, 173, 172, 171, 170, 145, 146, 147, 148, 149, 150, 151, 126, 125, 124, 123, 122, 121, 144, 221, 222, 223, 176, 204, 227, 244, 245, 228, 205, 177, 153, 178, 206, 229, 230, 207, 179, 154, 155, 180, 208, 231, 209, 181, 156, 132, 157, 182, 210, 211, 183, 158, 133, 110, 109, 108, 89, 90, 91, 92, 111, 134, 159, 184, 212, 213, 185, 186, 187, 163, 162, 161, 160, 135, 136, 137, 138, 139, 116, 115, 114, 113, 112, 93, 94, 95, 96, 97, 78, 77, 76, 75, 74, 73, 72, 55, 56, 57, 58, 59, 60, 61, 62, 80, 79, 98, 99, 118, 117, 140, 141, 119, 100, 81, 63, 47, 48, 64, 82, 101, 120, 102, 83, 65, 49, 35, 36, 50, 66, 84, 85, 67, 51, 37, 25, 24, 23, 22, 21, 30, 31, 32, 33, 34, 46, 45, 44, 43, 42, 71, 70, 88, 87, 86, 107, 106, 105, 104, 103, 127, 152, 128, 129, 130, 131, 175, 68, 69, 53, 52, 38, 39, 27, 26, 16, 17, 18, 19, 20, 12, 11, 10, 9, 8, 4, 5, 6, 3, 2, 7, 13, 1, 29, 41, 54, 40, 28, 15, 14])

print type(Chosen_Columns_best_result)
DistancePenalty = 96
SCI4 = 1
fc = 0
PeriodNumbers = []
TotalTime = 0
RandExtNumbList = []
fc, PeriodNumbers,TotalTime,RandExtNumbList = f(Chosen_Columns_best_result[:])


You forgot to return anything from your function. If nothing is explicitly returned then None is returned.