How the first or the second array traversal wow, there are big brother big sister to give some guidance,
CodePudding user response:
Def visit (list1) : For I in list1: If isinstance (I, (the list, the set)) : Print (" % s -- -- -- -- -- - start "% (I)) Visit (I) Print (" % s "-- -- -- -- -- - end % (I)) The else: Print (I) 60,61,62,63,64,65 list1=[1, 2, 3, 4, 5, [], 7, 8,,91 [90]] Visit (list1) CodePudding user response:
The
reference 1/f, 502203305 response: Def visit (list1) : For I in list1: If isinstance (I, (the list, the set)) : Print (" % s -- -- -- -- -- - start "% (I)) Visit (I) Print (" % s "-- -- -- -- -- - end % (I)) The else: Print (I) 60,61,62,63,64,65 list1=[1, 2, 3, 4, 5, [], 7, 8,,91 [90]] Visit (list1) Special thank you CodePudding user response:
Fyi: #! The/usr/bin/env python Def visit (LST) : Print (", "end=" ") For l in LST: If isinstance (l, a list) : Visit (l) The else: Print (l, end="") Print ("] ", end="") 60,61,62,63,64,65 LST=[1, 2, 3, 4, 5, [], 7, 8,,91 [90]] Visit (LST) CodePudding user response:
reference ctrigger reply: 3/f are for reference only: #! The/usr/bin/env python Def visit (LST) : Print (", "end=" ") For l in LST: If isinstance (l, a list) : Visit (l) The else: Print (l, end="") Print ("] ", end="") 60,61,62,63,64,65 LST=[1, 2, 3, 4, 5, [], 7, 8,,91 [90]] Visit (LST) Very thank you hey hey