First, IDLE
1.TAB Completion: Embed some code first, then press the TAB key. Idle will provide some suggestions to help you complete this statement.
2. Fallback code statement: When using the shell, alt-p, fallback to the code statement entered before idle; alt-n, move to the next code statement, if any. Under Mac, change alt to CTRL.
Two, nested list
Output nested list:
Movies = ["The Holy Grail", 1975,"Terry Jones & Terry Gilliam", 91, ["Graham Chapman", ["Michael Palin","John Cleese", "Terry Gilliam","Eric Idle","Terry Jones"]]]Print(Movies) forXinchMovies:ifisinstance (x,list): forYinchx:ifisinstance (y,list): forZinchy:Print(z)Else: Print(y)Else: Print(x)
Improvement: Changing the repeating code into a function
Movies = ["The Holy Grail", 1975,"Terry Jones & Terry Gilliam", 91, ["Graham Chapman", ["Michael Palin","John Cleese", "Terry Gilliam","Eric Idle","Terry Jones"]]]defprint_lol (a_list): forEach_itemincha_list:ifisinstance (Each_item, list): Print_lol (Each_item)Else: Print(Each_item) print_lol (Movies)
Third, BIF
Isinstance (), Len (), print ()
Head First Python (i)