To create a two-dimensional list:
Animals = []for i in Range (5): Animals.append (["O" * 5])
Read the two-dimensional list:
Print Animals[0][0]
Use index in list for:
choices = [' pizza ', ' pasta ', ' salad ', ' nachos ']print ' Your choices is: ' for index, item in enumerate (choices): Print in Dex + 1, item range has negative usage: str reverse output, str converted to listdef reverse (text): Length_of_text = Len (text) Length_of_text-= 1 Text_list = list (text) stuff = [] for n in range (length_of_text,-1,-1): Stuff.append (Text_list[n]) answer = "". Join (Stuff) return answer range (5,-1,-1) #[5,4,3,2,1] combines the use of range and list to index the indextext_list[5],text_list[4 of the list,.. Implements the ability to convert a string to list and then reverse output.
This article is from "Willow Shore" blog, please be sure to keep this source http://jackzones.blog.51cto.com/5001676/1725352
Codecademy notes, two-dimensional list