python - NoneType Error with Function -


first, sorry bad english. have problem, function return me nonetype error when executed more 2 time

def random(k, position, impossible):     """permet de générer des case où il n'y pas encore de navires placé     et qui soit possible (éviter que le bateau soit sur deux lignes),     l'argument k correspond au navire en cours de placement     """     global cases_occupées_bot     case = randint(0,99)     print("salut !", k, position, case, impossible)     if k == 0: #porte-avion (5 cases)         if (position == 0 ,                  len(set((case, case)).intersection(set(impossible))) == 0 ,                 len(set((case, case+1, case+2, case+3, case+4)).intersection(                     set(cases_occupées_bot))) == 0):             cases_occupées_bot.extend([case, case+1, case+2, case+3, case+4])             return case         elif (position == 1 ,                 len(set((case, case)).intersection(set(impossible))) == 0 ,                 len(set((case, case+10, case+20, case+30,case+40)).intersection(                     set(cases_occupées_bot))) == 0):             cases_occupées_bot.extend([case, case+10, case+20, case+30, case+40])             return case         else:             random(k, position, impossible) 

for test function use:

random(0,0,[9,19,29,39,49,59,69,79,89,99,8,18,28,38,48,58,68,78,88,98,7,17,27,37,47,57,67,77,87,97,6,16,26,36,46,56,66,76,86,96]) 

i know come from, in advance !

you need return result of recursive call in last line.

return random(k,position,impossible) 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -