![]() Again, each value is numbered starting from zero, for easy reference. ![]() The values that you give it first up, are the values that you are stuck with for the rest of the program. Tuples are just like lists, but you can't change their values.You can remove values from the list, and add new values to the end. Each one of them is numbered, starting from zero - the first one is numbered zero, the second 1, the third 2, etc. Lists are what they seem - a list of values.How would you do that? The Solution - Lists, Tuples, and Dictionariesįor these three problems, Python uses three different solutions - Tuples, lists, and dictionaries: What about a phone book? For that you need to do a bit of referencing - you would have a list of names, and attached to each of those names, a phone number. You might get new cats, some may die, some may become your dinner (we should trade recipies!). Or maybe a long list of information, that does change over time? Say, for example, the names of all your cats. Variables are great at what they do - storing a piece of information that may change over time.īut what if you need to store a long list of information, which doesn't change over time? Say, for example, the names of the months of the year. ![]() They may regurgitate (just not on the carpet.) that information at any point, and their bit of information can be changed at any time. Think about it - variables store one bit of information. We're going back to something simple - variables - but a little more in depth. Your brain still hurting from the last lesson? Never worry, this one will require a little less thought. Tuples, Lists, and Dictionaries Introduction
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |