Codecademy notes, two-dimensional list

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.